Skip to content

Add installer teardown for LUKS and LVM layouts#4496

Open
kill74 wants to merge 1 commit intoarchlinux:masterfrom
kill74:fix/teardown-install-layout
Open

Add installer teardown for LUKS and LVM layouts#4496
kill74 wants to merge 1 commit intoarchlinux:masterfrom
kill74:fix/teardown-install-layout

Conversation

@kill74
Copy link
Copy Markdown

@kill74 kill74 commented Apr 28, 2026

Fixes #4491

PR Description

This PR adds a guarded teardown path to Installer so archinstall cleans up the target storage stack after an installation attempt exits.

The teardown runs from Installer.__exit__() and is triggered only after mount_ordered_layout() has started. It handles:

  • Recursive unmounting of the installation target
  • Swap deactivation
  • LUKS mapper closure
  • LVM logical volume deactivation
  • LVM volume group deactivation
  • Final udev sync

The cleanup order follows the reverse of the setup topology:

Configuration Cleanup Order
Plain LUKS Unmount → close LUKS mappings
Plain LVM Unmount → deactivate LVM
LVM on LUKS Unmount → deactivate LVM → close LUKS
LUKS on LVM Unmount → close LUKS → deactivate LVM

Cleanup is best-effort so teardown does not mask the original installation error.

Tests and Checks

  • I have tested the code!

Ran successfully:

python3 -m compileall archinstall/lib/installer.py archinstall/lib/disk/lvm.py

Attempted:

python -m pytest tests

The pytest suite did not complete in the local WSL environment because test collection fails before reaching this change with an unrelated error from archinstall/lib/output.py:

NameError: name 'DataclassInstance' is not defined

That file is outside the scope of this PR.

Manual validation still needed on Arch/live ISO for:

  • Plain LUKS
  • Plain LVM
  • LVM on LUKS
  • LUKS on LVM
  • No leftover /mnt mounts after installer exit
  • No leftover install-created LUKS mappings after installer exit
  • LVM volumes/groups deactivated after installer exit

@kill74 kill74 requested a review from Torxed as a code owner April 28, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request: Add teardown function

1 participant