From 42791a1a7ce08851a92db16ae8d7ce11ee8fb09b Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Tue, 26 Mar 2024 11:32:41 +0100 Subject: revert 7f18485: improve uefi detection mechanism Make is_uefi_supported() only check for /sys/firmware/efi as get_efi_partition() will detect a missing ESP or an invalid partition scheme. Stop using get_efi_partition() inside is_uefi_supported() as the former is eventually called in every UEFI related code. UEFI supports both MBR and GPT as partition schemes and this is a required change to handle the particular case of Windows not being able to boot UEFI from a MBR partition scheme. --- src/utils/boot.py | 2 +- src/utils/uefi.py | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/utils/boot.py b/src/utils/boot.py index 04cae8e..baa3f49 100644 --- a/src/utils/boot.py +++ b/src/utils/boot.py @@ -111,7 +111,7 @@ def boot_os_at(disk, part): if not mount_mkdir(device, mountpoint): raise RuntimeError(f'Cannot probe OS family. Unable to mount {device} at {esp_mountpoint}.') - is_uefi = is_uefi_supported(disk) + is_uefi = is_uefi_supported() if is_uefi: logging.info('UEFI support detected') else: diff --git a/src/utils/uefi.py b/src/utils/uefi.py index e113512..9bc2e09 100644 --- a/src/utils/uefi.py +++ b/src/utils/uefi.py @@ -11,7 +11,6 @@ import logging import os import shlex import subprocess -from src.utils.disk import get_efi_partition import fdisk @@ -47,17 +46,8 @@ def _check_efibootmgr_json(): return supported -def is_uefi_supported(disknum): - 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 is_uefi_supported(): + return os.path.exists("/sys/firmware/efi") def run_efibootmgr_json(): -- cgit v1.2.3-18-g5258