Move udev_sync() to disk.utils (#4281)

This commit is contained in:
codefiles 2026-03-03 20:43:47 -05:00 committed by GitHub
parent 813b9b34b3
commit 452abe4277
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 16 deletions

View File

@ -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()

View File

@ -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)

View File

@ -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,