From 80125623027283c9a9d94a98bea442b1f0c11206 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Wed, 13 Mar 2024 12:18:35 +0100 Subject: utils: implement BIOS boot for windows Create ogboot.me and ogboot.secondboot as empty files and ogboot.firstboot with the value "iniciado" in the root of the BIOS Windows system partition. The files must contain data for GRUB to be able to write content, therefore these are created containing 3072 null bytes. The Windows boot process is handled by the "pxe" profile. There the files ogboot.me, ogboot.firstboot and ogboot.secondboot are used as a state machine to chose between booting Windows and ogLive. The first Windows boot happens if ogboot.me and ogboot.firstboot are identical, then "iniciado" is written in ogboot.firstboot. We skip this stage as we create ogboot.firstboot with 'iniciado'. The second Windows boot occurs if ogboot.me and ogboot.secondboot are boot identical, then "iniciado" is written in ogboot.secondboot. After the Windows boot ogLive is booted. --- src/utils/boot.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/utils') diff --git a/src/utils/boot.py b/src/utils/boot.py index 724fc06..a5ff04b 100644 --- a/src/utils/boot.py +++ b/src/utils/boot.py @@ -19,9 +19,6 @@ from src.utils.uefi import * from src.utils.fs import * -def _boot_bios_legacy(disk, part, mountpoint): - raise NotImplementedError - def _boot_bios_linux(disk, part, mountpoint): logging.info(f'Booting Linux system') @@ -47,7 +44,16 @@ def _boot_bios_linux(disk, part, mountpoint): def _boot_bios_windows(disk, part, mountpoint): logging.info(f'Booting Windows system') - _boot_bios_legacy(disk, part, mountpoint) + try: + with open(f'{mountpoint}/ogboot.me', 'w') as f: + f.write('\0' * (3072)) + with open(f'{mountpoint}/ogboot.firstboot', 'w') as f: + f.write('iniciado') + f.write('\0' * (3072 - 8)) + with open(f'{mountpoint}/ogboot.secondboot', 'w') as f: + f.write('\0' * (3072)) + except OSError as e: + raise RuntimeError(f'Could not create ogboot files in Windows partition: {e}') def _boot_uefi_windows(disk, part, mountpoint): logging.info(f'Booting windows system') -- cgit v1.2.3-18-g5258