Repository navigation
fix: unmount the whole subtree below a mapper in Luks2.lock() - #4864
Open
xander-lin wants to merge 1 commit into
Open
xander-lin wants to merge 1 commit into
xander-lin wants to merge 1 commit into
Conversation
`lock()` looked one level below the mapper and unmounted the mountpoints it found there. On LUKS-on-LVM nothing is mounted on that level: the mountpoints live on the logical volumes, which are grandchildren of the mapper. They stayed mounted, so `cryptsetup close` found the device busy and the mapper could not be closed - which is what the cleanup before a re-run does. Walk the whole subtree instead, children before parents.
Member
|
I sense this is LLM contributions, but the isssue is valid and the fix seems reasonable. |
h8d13
added a commit
to h8d13/archinstoo
that referenced
this pull request
Oct 28, 2026
* fix(disk): skip deleted partitions when mounting and booting A DELETE entry keeps its dev_path, mountpoint and flags. The menu sorts deletes first, so on a reinstall the ESP/boot/root lookups returned the old partitions, and the mount stage mounted or swapon'd them. Filter is_delete() there and when preparing fs packages. Port of archlinux/archinstall#4861. Signed-off-by: h8d13 <hadean-eon-dev@proton.me> * fix(disk): never offer or accept a zero-length partition A free gap between off-grain neighbours can round below 1 MiB once snapped, and a config could carry a 0 B create. Keep only the aligned span in FreeSpace so the menu's buffer check drops such gaps, and reject a create without a length. Port of archlinux/archinstall#4862. Signed-off-by: h8d13 <hadean-eon-dev@proton.me> * fix(disk): swapoff and unmount by device during cleanup [SWAP] is dropped from lsblk mountpoints for the menu, so umount() never saw an active swap and left it on before partitioning. Luks2.lock() passed mountpoints to umount(), which lsblk rejects, so any mounted mapper failed with 'Failed to read disk'. Swapoff swap devices and unmount the mapper by its path. Port of archlinux/archinstall#4864 and #4865. Signed-off-by: h8d13 <hadean-eon-dev@proton.me> * fix(disk): reject lvm with plain luks, no_encryption is plain lvm perform_lvm_operations took the encrypted path for any enc config, which only handles lvm_on_luks/luks_on_lvm, so luks or no_encryption with lvm_config built no volume group. Reject luks at parse time and route no_encryption to the plain lvm setup. Port of archlinux/archinstall#4863 (that part only). Signed-off-by: h8d13 <hadean-eon-dev@proton.me> --------- Signed-off-by: h8d13 <hadean-eon-dev@proton.me>
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.
Summary
Luks2.lock()unmounts what is mounted below the mapper before closing it, but it only looks onelevel down:
On LUKS-on-LVM nothing is mounted at that level. The layout looks like this:
The mountpoints are on the logical volumes, two levels below the mapper, so
child.mountpointsisempty for every child that matters. Nothing is unmounted, and
cryptsetup closerefuses to close amapper that still has a mounted filesystem below it:
lock()is whatDeviceHandler.umount_all_existing()calls for every existingCRYPTO_LUKSpartition before a new installation starts, so this is the path taken when installing over a
previous LUKS-on-LVM system - the partition cannot be released and the installation stops.
Fix
Walk the whole subtree below the mapper and unmount children before parents, so the order holds
however deep the stack is:
Unmounting is done by device path rather than by mountpoint, so a mountpoint that lsblk reports as
[SWAP]- a display marker, not a path - cannot reachumount().Reproducer
The device tree above is what
lsblkreports for a LUKS container holding an LVM volume group. Tosee the difference without building one, the shape can be handed to
lock()directly:On master:
With the patch:
Verification boundary
This was verified with a stubbed device tree, not by building a real LUKS-on-LVM stack - the
machine this was written on has no
lvm2. Thelsblkshape it relies on is the one in thediagram above, which is what
lsblkreports forsda1 -> cryptlvm -> vg -> vg-root. Anyonereviewing with
lvm2available can confirm it in a few commands; the code path is the same one.Tests
tests/test_luks_lock_subtree.py:lock()unmounts the logical volumes under a mapper (this is what fails on master);lock()still runscryptsetup closefor each child.