[Bug 2111762] Re: BTRFS swap not reliably mounted when using keyfile with encrypted Kubuntu

Chris 2111762 at bugs.launchpad.net
Mon May 26 23:10:25 UTC 2025


It seems related to cryptsetup, although possibly the bug is only
triggered by it.

** Package changed: ubuntu => cryptsetup (Ubuntu)

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to cryptsetup in Ubuntu.
https://bugs.launchpad.net/bugs/2111762

Title:
  BTRFS swap not reliably mounted when using keyfile with encrypted
  Kubuntu

Status in cryptsetup package in Ubuntu:
  New

Bug description:
  If I install either Kubuntu 24.04.2 or 25.04 with a swapfile & BTRFS
  on an encrypted (cryptsetup) partition, and add a keyfile, then
  usually (but not always) the /swap subvolume fails to mount, such that
  /swap/swapfile doesn't exist, and so "cat /proc/swap" lists nothing.
  This occurs on two very different laptops & a desktop PC.

  After installing Kubuntu, I perform these very minor changes:
  $ sudo cryptsetup luksAddKey /dev/sda3 /media/chris/USB/test.key
  $ sudo vim /etc/crypttab
  $ sudo update-initramfs -u #-k all

  Here is my slightly modified /etc/crypttab:
  ~~~
  #luks-09135e69-3422-4c29-b2a2-691197225802 UUID=09135e69-3422-4c29-b2a2-691197225802     none
  luks-09135e69-3422-4c29-b2a2-691197225802 UUID=09135e69-3422-4c29-b2a2-691197225802	/dev/disk/by-label/USB:/test.key	keyscript=passdev
  ~~~

  For reference, these are the relevant (but UNchanged) entries in /etc/fstab:
  ~~~
  /dev/mapper/luks-09135e69-3422-4c29-b2a2-691197225802 /swap          btrfs   subvol=/@swap,defaults 0 0
  /swap/swapfile                            swap           swap    defaults   0 0
  ~~~

  But I've also seen similar behaviour if I add a bind mount inside the
  /home subvolume, so it's not swap specific.  Instead I suspect it's
  because cryptsetup is not ready when it tries to mount the /swap
  subvolume, as I see the following in the journal:

  ~~~
  chris at chris-test:~$ journalctl -b -g "cryptsetup|luks|swap|local-fs.target|home.mount"
  May 26 22:37:42 chris-test kernel: Command line: BOOT_IMAGE=/vmlinuz-6.14.0-15-generic root=UUID=69898faf-5ddc-425a-9e2f-e4798fa1426e ro rootflags=subvol=@ quiet rd.luks.uuid=09135e69-3422-4c29-b2a2-691197225802 splash vt.handoff=7
  May 26 22:37:42 chris-test kernel: Kernel command line: BOOT_IMAGE=/vmlinuz-6.14.0-15-generic root=UUID=69898faf-5ddc-425a-9e2f-e4798fa1426e ro rootflags=subvol=@ quiet rd.luks.uuid=09135e69-3422-4c29-b2a2-691197225802 splash vt.handoff=7
  May 26 22:37:42 chris-test kernel: Spectre V1 : Mitigation: usercopy/swapgs barriers and __user pointer sanitization
  May 26 22:37:43 chris-test kernel: BTRFS: device label kubuntu_2504 devid 1 transid 140 /dev/mapper/luks-09135e69-3422-4c29-b2a2-691197225802 (252:0) scanned by mount (314)
  May 26 22:37:43 chris-test systemd[1]: systemd 257.4-1ubuntu3 running in system mode (+PAM +AUDIT +SELINUX +APPARMOR +IMA +IPE +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBCRYPTSETUP_PLUGINS +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +BPF_FRAMEWORK +BTF -XKBCOMMON -UTMP +SYSVINIT +LIBARCHIVE)
  May 26 22:37:43 chris-test systemd[1]: Created slice system-systemd\x2dcryptsetup.slice - Encrypted Volume Units Service Slice.
  May 26 22:37:43 chris-test systemd[1]: Expecting device dev-mapper-luks\x2d09135e69\x2d3422\x2d4c29\x2db2a2\x2d691197225802.device - /dev/mapper/luks-09135e69-3422-4c29-b2a2-691197225802...
  May 26 22:37:43 chris-test systemd[1]: Mounting run-systemd-cryptsetup-keydev\x2dluks\x2d09135e69\x2d3422\x2d4c29\x2db2a2\x2d691197225802.mount - /run/systemd/cryptsetup/keydev-luks-09135e69-3422-4c29-b2a2-691197225802...
  May 26 22:37:47 chris-test mount[384]: mount: /run/systemd/cryptsetup/keydev-luks-09135e69-3422-4c29-b2a2-691197225802: special device /test.key does not exist.
  May 26 22:37:47 chris-test umount[438]: umount: /run/systemd/cryptsetup/keydev-luks-09135e69-3422-4c29-b2a2-691197225802: not mounted.
  May 26 22:37:43 chris-test systemd[1]: run-systemd-cryptsetup-keydev\x2dluks\x2d09135e69\x2d3422\x2d4c29\x2db2a2\x2d691197225802.mount: Mount process exited, code=exited, status=32/n/a
  May 26 22:37:43 chris-test systemd[1]: run-systemd-cryptsetup-keydev\x2dluks\x2d09135e69\x2d3422\x2d4c29\x2db2a2\x2d691197225802.mount: Failed with result 'exit-code'.
  May 26 22:37:43 chris-test systemd[1]: Failed to mount run-systemd-cryptsetup-keydev\x2dluks\x2d09135e69\x2d3422\x2d4c29\x2db2a2\x2d691197225802.mount - /run/systemd/cryptsetup/keydev-luks-09135e69-3422-4c29-b2a2-691197225802.
  May 26 22:37:43 chris-test systemd[1]: Dependency failed for systemd-cryptsetup at luks\x2d09135e69\x2d3422\x2d4c29\x2db2a2\x2d691197225802.service - Cryptography Setup for luks-09135e69-3422-4c29-b2a2-691197225802.
  May 26 22:37:43 chris-test systemd[1]: Dependency failed for cryptsetup.target - Local Encrypted Volumes.
  May 26 22:37:43 chris-test systemd[1]: cryptsetup.target: Job cryptsetup.target/start failed with result 'dependency'.
  May 26 22:37:43 chris-test systemd[1]: Dependency failed for dev-mapper-luks\x2d09135e69\x2d3422\x2d4c29\x2db2a2\x2d691197225802.device - /dev/mapper/luks-09135e69-3422-4c29-b2a2-691197225802.
  May 26 22:37:43 chris-test systemd[1]: Dependency failed for swap.mount - /swap.
  May 26 22:37:43 chris-test systemd[1]: Dependency failed for swap-swapfile.swap - /swap/swapfile.
  May 26 22:37:43 chris-test systemd[1]: Dependency failed for swap.target - Swaps.
  May 26 22:37:43 chris-test systemd[1]: swap.target: Job swap.target/start failed with result 'dependency'.
  May 26 22:37:43 chris-test systemd[1]: swap-swapfile.swap: Job swap-swapfile.swap/start failed with result 'dependency'.
  May 26 22:37:43 chris-test systemd[1]: Dependency failed for local-fs.target - Local File Systems.
  May 26 22:37:43 chris-test systemd[1]: local-fs.target: Job local-fs.target/start failed with result 'dependency'.
  May 26 22:37:43 chris-test systemd[1]: local-fs.target: Triggering OnFailure= dependencies.
  May 26 22:37:43 chris-test systemd[1]: swap.mount: Job swap.mount/start failed with result 'dependency'.
  May 26 22:37:43 chris-test systemd[1]: Dependency failed for home.mount - /home.
  May 26 22:37:43 chris-test systemd[1]: home.mount: Job home.mount/start failed with result 'dependency'.
  May 26 22:37:43 chris-test systemd[1]: dev-mapper-luks\x2d09135e69\x2d3422\x2d4c29\x2db2a2\x2d691197225802.device: Job dev-mapper-luks\x2d09135e69\x2d3422\x2d4c29\x2db2a2\x2d691197225802.device/start failed with result 'dependency'.
  May 26 22:37:43 chris-test systemd[1]: systemd-cryptsetup at luks\x2d09135e69\x2d3422\x2d4c29\x2db2a2\x2d691197225802.service: Job systemd-cryptsetup at luks\x2d09135e69\x2d3422\x2d4c29\x2db2a2\x2d691197225802.service/start failed with result 'dependency'.
  May 26 22:37:43 chris-test systemd[1]: Reached target blockdev at dev-mapper-luks\x2d09135e69\x2d3422\x2d4c29\x2db2a2\x2d691197225802.target - Block Device Preparation for /dev/mapper/luks-09135e69-3422-4c29-b2a2-691197225802.
  May 26 22:37:43 chris-test systemd[1]: Started keydev-luks-09135e69-3422-4c29-b2a2-691197225802-umount.service.
  May 26 22:37:43 chris-test systemd[1]: Stopped target blockdev at dev-mapper-luks\x2d09135e69\x2d3422\x2d4c29\x2db2a2\x2d691197225802.target - Block Device Preparation for /dev/mapper/luks-09135e69-3422-4c29-b2a2-691197225802.
  May 26 22:37:43 chris-test systemd[1]: keydev-luks-09135e69-3422-4c29-b2a2-691197225802-umount.service: Deactivated successfully.
  May 26 22:37:55 chris-test systemd[1]: Mounting home.mount - /home...
  May 26 22:37:55 chris-test systemd[1]: Mounted home.mount - /home.
  ~~~

  And after booting I can enable swap with "sudo mount /swap" followed
  by "sudo swapon --all".  I've tried working-around this bug myself,
  but the problem remains no matter what changes I make to /etc/fstab or
  /etc/crypttab - although I'm no expert, so perhaps there is some easy
  fix that I've overlooked.

  NOTE: Once crypttab uses keyscript=passdev, Kubuntu typically offers
  "emergency mode" (presumably due to the above failures) - but as long
  as I don't touch it, then it usually finishes booting normally,
  leaving me at the Plasma desktop.  However if I touch "emergency mode"
  at all (even ctrl-D), then usually the swap is working (I presume it
  retries something & finds it's able to mount /swap).

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cryptsetup/+bug/2111762/+subscriptions




More information about the foundations-bugs mailing list