From 452abe42777c5ec58c033c0d309d476ce9b247e3 Mon Sep 17 00:00:00 2001 From: codefiles <11915375+codefiles@users.noreply.github.com> Date: Tue, 3 Mar 2026 20:43:47 -0500 Subject: [PATCH] Move udev_sync() to disk.utils (#4281) --- archinstall/lib/disk/device_handler.py | 28 +++++++++++++------------- archinstall/lib/disk/filesystem.py | 5 +++-- archinstall/lib/disk/utils.py | 7 +++++++ 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/archinstall/lib/disk/device_handler.py b/archinstall/lib/disk/device_handler.py index 98a10b79..2b4a56ec 100644 --- a/archinstall/lib/disk/device_handler.py +++ b/archinstall/lib/disk/device_handler.py @@ -6,7 +6,14 @@ from pathlib import Path 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 @@ class DeviceHandler: 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 @@ class DeviceHandler: 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 @@ class DeviceHandler: 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 @@ class DeviceHandler: 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 @@ class DeviceHandler: 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 @@ class DeviceHandler: # 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 @@ class DeviceHandler: 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 d1c8593b..8deeae98 100644 --- a/archinstall/lib/disk/filesystem.py +++ b/archinstall/lib/disk/filesystem.py @@ -4,6 +4,7 @@ from pathlib import Path 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 @@ class FilesystemHandler: 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 @@ class FilesystemHandler: 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 6f490465..808ff451 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,