utils: improve uefi detection mechanism

Checking the existence /sys/firmware/efi as it might appear
sometimes in BIOS installs if the BIOS configuration is not
proper. Checking for the EFI partition is the safest method
to veryfy the install type.
master
Alejandro Sirgo Rica 2024-03-07 09:46:41 +01:00 committed by lupoDharkael
parent 9970c8e33d
commit 7f18485eff
3 changed files with 14 additions and 4 deletions

View File

@ -262,7 +262,7 @@ class OgLiveOperations:
disk = request.getDisk() disk = request.getDisk()
partition = request.getPartition() partition = request.getPartition()
if is_uefi_supported(): if is_uefi_supported(disk):
logging.info('UEFI support detected') logging.info('UEFI support detected')
logging.info(f'Booting disk={disk} partition={partition}') logging.info(f'Booting disk={disk} partition={partition}')
boot_os_at(int(disk), int(partition)) boot_os_at(int(disk), int(partition))

View File

@ -69,7 +69,7 @@ def _boot_uefi_linux(disk, part, mountpoint):
umount(esp_mountpoint) 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(disk):
raise NotImplementedError('BIOS booting is not implemented yet') raise NotImplementedError('BIOS booting is not implemented yet')
device = get_partition_device(disk, part) device = get_partition_device(disk, part)

View File

@ -11,6 +11,7 @@ import logging
import os import os
import shlex import shlex
import subprocess import subprocess
from src.utils.disk import get_efi_partition
import fdisk import fdisk
@ -46,8 +47,17 @@ def _check_efibootmgr_json():
return supported return supported
def is_uefi_supported(): def is_uefi_supported(disknum):
return True if os.path.exists("/sys/firmware/efi") else False is_supported = os.path.exists("/sys/firmware/efi")
if is_supported:
try:
get_efi_partition(disknum)
except Exception as e:
logging.info(e)
is_supported = False
return is_supported
def run_efibootmgr_json(): def run_efibootmgr_json():