Skip to content

fix: disable active swap partitions in umount_all_existing() - #4857

Open
Kolgrim33 wants to merge 1 commit into
archlinux:masterfrom
Kolgrim33:fix/swapoff-existing-partitions
Open

Kolgrim33 wants to merge 1 commit into
archlinux:masterfrom
Kolgrim33:fix/swapoff-existing-partitions

Conversation

@Kolgrim33

Copy link
Copy Markdown

PR Description:

When an existing swap partition is active on a target disk, lsblk --json reports "[SWAP]" in its mountpoints list.

Previously, DeviceHandler.umount_all_existing() passed FilesystemType.LINUX_SWAP partitions to umount(partition.path, recursive=True), which attempted to execute umount -R [SWAP] (failing with exit code 32) and never disabled active swap on the partition—causing subsequent parted operations to fail with Device or resource busy.

This PR:

  • Adds a swapoff() helper in archinstall.lib.disk.utils that disables swap when [SWAP] is present in lsblk_info.mountpoints.
  • Calls swapoff(partition.path) for FilesystemType.LINUX_SWAP partitions in DeviceHandler.umount_all_existing().
  • Filters out Path('[SWAP]') in umount() so pseudo-mountpoints are never passed to umount.
  • Adds unit tests in tests/test_swapoff_existing.py.

Tests and Checks

  • I have tested the code!

@Kolgrim33
Kolgrim33 requested a review from Torxed as a code owner October 25, 2026 18:55
When an existing swap partition is active on a target disk, lsblk
reports '[SWAP]' in its mountpoints array.

Previously, DeviceHandler.umount_all_existing() called umount() on
LINUX_SWAP partitions, causing umount() to execute 'umount -R [SWAP]'
(which fails with exit code 32) and leaving swap active on the device so
subsequent partition table modifications fail with 'Device or resource
busy'.

Add a swapoff() helper in archinstall.lib.disk.utils, call it for
LINUX_SWAP partitions in umount_all_existing(), and filter out '[SWAP]'
in umount().
@Kolgrim33
Kolgrim33 force-pushed the fix/swapoff-existing-partitions branch from 17594da to b15f2d8 Compare October 25, 2026 18:59

@h8d13 h8d13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks okay to me.

Closes: #4235

@h8d13

h8d13 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Not sure about the policy here with tests, we used not to add too many and just rely on repro then re-run.

This branch has not been deployed

No deployments
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.

3 participants