diff --git a/archinstall/lib/disk/device_handler.py b/archinstall/lib/disk/device_handler.py index 98a10b79ac..2b4a56ec4a 100644 --- a/archinstall/lib/disk/device_handler.py +++ b/archinstall/lib/disk/device_handler.py @@ -6,7 +6,14 @@ from parted import Device, Disk, DiskException, FileSystem, Geometry, IOException, Partition, PartitionException, freshDisk, getAllDevices, getDevice, newDisk from archinstall.lib.command import SysCommand, SysCommandWorker -from archinstall.lib.disk.utils import find_lsblk_info, get_all_lsblk_info, get_lsblk_info, mount, umount +from archinstall.lib.disk.utils import ( + find_lsblk_info, + get_all_lsblk_info, + get_lsblk_info, + mount, + udev_sync, + umount, +) from archinstall.lib.exceptions import DiskError, SysCallError, UnknownFilesystemFormat from archinstall.lib.luks import Luks2, unlock_luks2_dev from archinstall.lib.models.device import ( @@ -55,7 +62,7 @@ def partition_table(self) -> PartitionTable: def load_devices(self) -> None: block_devices = {} - self.udev_sync() + udev_sync() all_lsblk_info = get_all_lsblk_info() devices = getAllDevices() devices.extend(self.get_loop_devices()) @@ -288,7 +295,7 @@ def encrypt( key_file = luks_handler.encrypt(iter_time=iter_time) - self.udev_sync() + udev_sync() luks_handler.unlock(key_file=key_file) @@ -319,7 +326,7 @@ def format_encrypted( key_file = luks_handler.encrypt(iter_time=enc_conf.iter_time) - self.udev_sync() + udev_sync() luks_handler.unlock(key_file=key_file) @@ -354,7 +361,7 @@ def lvm_pv_create(self, pvs: Iterable[Path]) -> None: SysCommand(cmd) # Sync with udev to ensure the PVs are visible - self.udev_sync() + udev_sync() def lvm_vg_create(self, pvs: Iterable[Path], vg_name: str) -> None: pvs_str = ' '.join(str(pv) for pv in pvs) @@ -364,7 +371,7 @@ def lvm_vg_create(self, pvs: Iterable[Path], vg_name: str) -> None: SysCommand(cmd) # Sync with udev to ensure the VG is visible - self.udev_sync() + udev_sync() def lvm_vol_create(self, vg_name: str, volume: LvmVolume, offset: Size | None = None) -> None: if offset is not None: @@ -604,7 +611,7 @@ def partition( # Sync with udev after wiping signatures if filtered_part: - self.udev_sync() + udev_sync() def detect_pre_mounted_mods(self, base_mountpoint: Path) -> list[DeviceModification]: part_mods: dict[Path, list[PartitionModification]] = {} @@ -673,12 +680,5 @@ def wipe_dev(self, block_device: BDevice) -> None: self._wipe(block_device.device_info.path) - @staticmethod - def udev_sync() -> None: - try: - SysCommand('udevadm settle') - except SysCallError as err: - debug(f'Failed to synchronize with udev: {err}') - device_handler = DeviceHandler() diff --git a/archinstall/lib/disk/filesystem.py b/archinstall/lib/disk/filesystem.py index d1c8593be9..8deeae98e2 100644 --- a/archinstall/lib/disk/filesystem.py +++ b/archinstall/lib/disk/filesystem.py @@ -4,6 +4,7 @@ from archinstall.lib.disk.device_handler import device_handler from archinstall.lib.disk.lvm import lvm_group_info, lvm_vol_info +from archinstall.lib.disk.utils import udev_sync from archinstall.lib.interactions.general_conf import confirm_abort from archinstall.lib.luks import Luks2 from archinstall.lib.models.device import ( @@ -53,7 +54,7 @@ def perform_filesystem_operations(self, show_countdown: bool = True) -> None: for mod in device_mods: device_handler.partition(mod) - device_handler.udev_sync() + udev_sync() if self._disk_config.lvm_config: for mod in device_mods: @@ -97,7 +98,7 @@ def _format_partitions( device_handler.format(part_mod.safe_fs_type, part_mod.safe_dev_path) # synchronize with udev before using lsblk - device_handler.udev_sync() + udev_sync() lsblk_info = device_handler.fetch_part_info(part_mod.safe_dev_path) diff --git a/archinstall/lib/disk/utils.py b/archinstall/lib/disk/utils.py index 6f4904658c..808ff451ed 100644 --- a/archinstall/lib/disk/utils.py +++ b/archinstall/lib/disk/utils.py @@ -129,6 +129,13 @@ def get_unique_path_for_device(dev_path: Path) -> Path | None: return None +def udev_sync() -> None: + try: + SysCommand('udevadm settle') + except SysCallError as err: + debug(f'Failed to synchronize with udev: {err}') + + def mount( dev_path: Path, target_mountpoint: Path,