Repository navigation
fix(#4182): detect pre-mounted encrypted root partitions - #4873
Open
devpryan7792 wants to merge 1 commit into
Open
devpryan7792 wants to merge 1 commit into
devpryan7792 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When performing an installation with an encrypted (LUKS) root partition using the pre-mounted configuration (
DiskLayoutType.Pre_mount),archinstallaborts with:Invalid configuration: root partition not foundeven when the encrypted container has been opened, formatted, and mounted to
/mnt(Closes #4182).Root Cause
/dev/nvme0n1p2opened as/dev/mapper/encrypted_p2and mounted at/mnt),lsblkoutputsmountpoints: []on the raw parent partition node/dev/nvme0n1p2, placing the active mountpoint['/mnt']on the decrypted child node (type="crypt")._PartitionInfo.from_partition()inarchinstall/lib/models/device.pyonly copiedmountpoints=lsblk_info.mountpoints, leavingpart_info.mountpointsempty._determine_fs_type()inarchinstall/lib/disk/device_handler.pyonly checkedlsblk_info.fstype, returningFilesystemType.CRYPTO_LUKSrather than the actual filesystem (e.g.ext4,btrfs) residing inside the mapped container.detect_pre_mounted_mods(base_mountpoint=Path('/mnt'))skipped the partition becausepart_info.mountpointswas empty, excluding the root partition fromdevice_modifications.global_menu.py:487,if root_partition is None:failed configuration validation with"Root partition not found".installer.py:_get_kernel_params_partition), if the root partition was encrypted via pre-mount,root_partition in self._disk_encryption.partitionsevaluated toFalse(sincedisk_config.disk_encryptionis not configured through the interactive partitioning menu), generating unbootableroot=PARTUUID=...kernel arguments withoutcryptdevice=and omitting theencrypthook inmkinitcpio.Fix
LsblkInfo(archinstall/lib/models/device.py):all_mountpointsproperty to recursively collect mountpoints across child block devices.find_child_by_type(device_type)to resolve child devices (e.g.type == 'crypt')._PartitionInfo&PartitionModification(archinstall/lib/models/device.py):is_encrypted: bool = Falseandmapper_name: str | None = None._PartitionInfo.from_partition(), detectis_encryptedand extractmapper_namefrom anycryptchild. Fall back tolsblk_info.all_mountpointswhenlsblk_info.mountpointsis empty.is_encryptedandmapper_nameintoPartitionModification.from_existing_partition().PartitionModification(falling back to'root','home', orainst<name>).DeviceHandler(archinstall/lib/disk/device_handler.py):_determine_fs_type(), inspect the decrypted crypt child'sfstypewhen present so filesystems inside opened LUKS containers are correctly identified.get_btrfs_info(), resolve the crypt child device when Btrfs resides on LUKS, reading subvolumes without attempting to mount raw encrypted partitions.Installer(archinstall/lib/installer.py):minimal_installation(), checkif part in self._disk_encryption.partitions or part.is_encrypted:so theencrypthook is added tomkinitcpiofor pre-mounted encrypted setups._get_kernel_params_partition(), includeor root_partition.is_encryptedand useroot_partition.mapper_name or 'root'to correctly formatcryptdevice=PARTUUID=...:<mapper_name>androot=/dev/mapper/<mapper_name>.Tests
Added
tests/test_pre_mount.py:test_lsblk_all_mountpoints_and_find_child: verifies recursive mountpoint aggregation and crypt child discovery.test_determine_fs_type_crypto_luks: verifies ext4 detection on opened LUKS partitions.test_determine_fs_type_crypto_luks_btrfs: verifies btrfs detection on opened LUKS partitions.test_detect_pre_mounted_encrypted_root: end-to-end detection of pre-mounted/boot(FAT32) and/(LUKS + ext4) at/mnt, verifyingis_root() == True,mountpoint == Path('/'),is_encrypted == True, andmapper_name == 'encrypted_p2'.test_detect_pre_mounted_encrypted_btrfs_root: verifies subvolume detection and mountpoint mapping for pre-mounted Btrfs on LUKS.test_kernel_params_pre_mounted_encrypted_root: verifies correctcryptdevice=androot=/dev/mapper/<mapper_name>kernel parameters.All 40 unit tests pass locally with
pytest tests. Formatting verified withruff checkandruff format.AI Usage Disclosure
Assisted with root cause analysis and test harness drafting using Google Antigravity. All changes, architecture paths, and test cases were thoroughly verified and reviewed by the author.