mirror of https://git.48k.eu/ogclient
live: drop IniciarSesion script when uefi booting into linux
Replace IniciarSesion script in favor of native Python code when booting a UEFI system into Linux. This completes the implementation of booting into an OS on a UEFI compliant system.master
parent
23b4b1feb6
commit
66941e9f79
|
@ -43,6 +43,30 @@ def _boot_uefi_windows(disk, part, mountpoint):
|
||||||
finally:
|
finally:
|
||||||
umount(esp_mountpoint)
|
umount(esp_mountpoint)
|
||||||
|
|
||||||
|
def _boot_uefi_linux(disk, part, mountpoint):
|
||||||
|
logging.info(f'Booting Linux system')
|
||||||
|
bootlabel = f'Part-{disk:02d}-{part:02d}'
|
||||||
|
esp, esp_disk, esp_part_number = get_efi_partition(disk)
|
||||||
|
esp_mountpoint = esp.replace('dev', 'mnt')
|
||||||
|
if not mount_mkdir(esp, esp_mountpoint):
|
||||||
|
raise RuntimeError(f'Unable to mount detected EFI System Partition at {esp} into {esp_mountpoint}')
|
||||||
|
|
||||||
|
loader_paths = [f'{esp_mountpoint}/EFI/{bootlabel}/Boot/shimx64.efi',
|
||||||
|
f'{esp_mountpoint}/EFI/ubuntu/shimx64.efi']
|
||||||
|
try:
|
||||||
|
for efi_app in loader_paths:
|
||||||
|
if os.path.exists(efi_app):
|
||||||
|
loader = efi_app[len(esp_mountpoint):]
|
||||||
|
logging.info(f'Found bootloader at ESP partition: {loader}')
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise RuntimeError(f'Unable to locate Linux EFI bootloader shimx64.efi')
|
||||||
|
|
||||||
|
efibootmgr_delete_bootentry(bootlabel)
|
||||||
|
efibootmgr_create_bootentry(esp_disk, esp_part_number, loader, bootlabel)
|
||||||
|
efibootmgr_bootnext(bootlabel)
|
||||||
|
finally:
|
||||||
|
umount(esp_mountpoint)
|
||||||
|
|
||||||
def boot_os_at(disk, part):
|
def boot_os_at(disk, part):
|
||||||
if not is_uefi_supported():
|
if not is_uefi_supported():
|
||||||
|
@ -55,9 +79,12 @@ def boot_os_at(disk, part):
|
||||||
|
|
||||||
logging.info(f'Booting system at {device}. Probing OS family...')
|
logging.info(f'Booting system at {device}. Probing OS family...')
|
||||||
os_family = get_os_family(mountpoint)
|
os_family = get_os_family(mountpoint)
|
||||||
if os_family == OSFamily.WINDOWS:
|
try:
|
||||||
_boot_uefi_windows(disk, part, mountpoint)
|
if os_family == OSFamily.WINDOWS:
|
||||||
elif os_family == OSFamily.LINUX:
|
_boot_uefi_windows(disk, part, mountpoint)
|
||||||
raise NotImplementedError('WIP: Linux UEFI boot not implemented yet.')
|
elif os_family == OSFamily.LINUX:
|
||||||
else:
|
_boot_uefi_linux(disk, part, mountpoint)
|
||||||
raise RuntimeError('Unknown OS family')
|
else:
|
||||||
|
raise RuntimeError('Unknown OS family')
|
||||||
|
finally:
|
||||||
|
umount(mountpoint)
|
||||||
|
|
Loading…
Reference in New Issue