LUKS swap partition destroyed upon reboot in 15.10 and 16.04

Bug #1567085 reported by vvhk on 2016-04-06
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Undecided
Unassigned

Bug Description

Usually on every reboot, sometimes every other, the LUKS encrypted swap partition is being destroyed. blkid shows no UUID for the partition, cryptsetup doesn't recognize it as a LUKS partition. This is logged:

Tra 06 23:05:41 deltalabs systemd[1]: dev-disk-by\x2duuid-9e972bb6\x2df6dc\x2d4e64\x2d8976\x2d2df54bd076f7.device: Job dev-disk-by\x2duuid-9e972bb6\x2df6dc\x2d4e64\x2d8976\x2d2df54bd076f7.device/start tim
Tra 06 23:05:41 deltalabs systemd[1]: Timed out waiting for device dev-disk-by\x2duuid-9e972bb6\x2df6dc\x2d4e64\x2d8976\x2d2df54bd076f7.device.
Tra 06 23:05:41 deltalabs systemd[1]: Dependency failed for Cryptography Setup for sda2_crypt.
Tra 06 23:05:41 deltalabs systemd[1]: Dependency failed for dev-mapper-sda2_crypt.device.
Tra 06 23:05:41 deltalabs systemd[1]: Dependency failed for /dev/mapper/sda2_crypt.
Tra 06 23:05:41 deltalabs systemd[1]: Dependency failed for Swap.
Tra 06 23:05:41 deltalabs systemd[1]: Dependency failed for Encrypted Volumes.

The disk layout is as follows:

Number Start End Size Type File system Flags
 1 1049kB 1024MB 1023MB primary ext4 boot
 2 1024MB 6024MB 5000MB primary
 3 6024MB 406GB 400GB primary
 4 406GB 430GB 24,0GB primary

#2 is LUKS swap and #3 is LUKS root, which obviously gets decrypted and mounted okay. This started happening after an update in 15.10 few weeks ago and aparently continues in 16.04 beta 2.

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: systemd 229-3ubuntu2 [modified: usr/share/dbus-1/system-services/org.freedesktop.systemd1.service]
ProcVersionSignature: Ubuntu 4.4.0-17.33-generic 4.4.6
Uname: Linux 4.4.0-17-generic x86_64
NonfreeKernelModules: zfs zunicode zcommon znvpair zavl nvidia_uvm nvidia
ApportVersion: 2.20.1-0ubuntu1
Architecture: amd64
CurrentDesktop: Unity
Date: Wed Apr 6 23:08:06 2016
InstallationDate: Installed on 2016-01-11 (86 days ago)
InstallationMedia: Ubuntu 15.10 "Wily Werewolf" - Release amd64 (20151021)
MachineType: To Be Filled By O.E.M. To Be Filled By O.E.M.
ProcKernelCmdLine: BOOT_IMAGE=/vmlinuz-4.4.0-17-generic root=UUID=73474220-1b0e-46bc-bba1-73fbbbc0a6f5 ro quiet splash
SourcePackage: systemd
SystemdDelta:
 [EXTENDED] /etc/systemd/system/display-manager.service → /lib/systemd/system/display-manager.service.d/xdiagnose.conf
 [EXTENDED] /lib/systemd/system/rc-local.service → /lib/systemd/system/rc-local.service.d/debian.conf
 [EXTENDED] /lib/systemd/system/systemd-timesyncd.service → /lib/systemd/system/systemd-timesyncd.service.d/disable-with-time-daemon.conf

 3 overridden configuration files found.
UpgradeStatus: Upgraded to xenial on 2016-04-05 (1 days ago)
dmi.bios.date: 11/26/2009
dmi.bios.vendor: American Megatrends Inc.
dmi.bios.version: P1.40
dmi.board.name: A770DE+
dmi.board.vendor: ASRock
dmi.chassis.asset.tag: To Be Filled By O.E.M.
dmi.chassis.type: 3
dmi.chassis.vendor: To Be Filled By O.E.M.
dmi.chassis.version: To Be Filled By O.E.M.
dmi.modalias: dmi:bvnAmericanMegatrendsInc.:bvrP1.40:bd11/26/2009:svnToBeFilledByO.E.M.:pnToBeFilledByO.E.M.:pvrToBeFilledByO.E.M.:rvnASRock:rnA770DE+:rvr:cvnToBeFilledByO.E.M.:ct3:cvrToBeFilledByO.E.M.:
dmi.product.name: To Be Filled By O.E.M.
dmi.product.version: To Be Filled By O.E.M.
dmi.sys.vendor: To Be Filled By O.E.M.

Martin Pitt (pitti) wrote :

Please give me the output of the following commands from a boot with a destroyed swap.

  cat /etc/fstab
  cat /etc/crypttab
  sudo blkid

From that boot, please also run

  sudo journalctl -b > /tmp/journal.txt

and attach /tmp/journal.txt here. Thanks!

Changed in systemd (Ubuntu):
status: New → Incomplete

$ cat /etc/fstab
#
/dev/mapper/sda3_crypt / ext4 noatime,errors=remount-ro 0 1
UUID=518c26ce-893a-49f4-ac53-1e2fac299a1e /boot ext4 defaults 0 2
/dev/mapper/sda2_crypt none swap sw 0 0

$ cat /etc/crypttab
sda2_crypt UUID=b2a2ed64-febc-4549-b07b-a9c927db52c9 none luks,swap,discard
sda3_crypt UUID=2a8c24b1-eb27-4100-b94a-f7bf8680728b none luks,discard

$ sudo blkid

/dev/mapper/sda3_crypt: UUID="73474220-1b0e-46bc-bba1-73fbbbc0a6f5" TYPE="ext4"
/dev/sda1: UUID="518c26ce-893a-49f4-ac53-1e2fac299a1e" TYPE="ext4" PARTUUID="dfa3c187-01"
/dev/sda2: PARTUUID="dfa3c187-02"
/dev/sda3: UUID="2a8c24b1-eb27-4100-b94a-f7bf8680728b" TYPE="crypto_LUKS" PARTUUID="dfa3c187-03"
/dev/sda4: PTUUID="06ce4633-dc19-4578-a481-bcfe0f440142" PTTYPE="gpt" PARTUUID="dfa3c187-04"
/dev/sdb1: LABEL="System Reserved" UUID="62D24140D24119A5" TYPE="ntfs" PARTUUID="a15007e4-01"
/dev/sdb2: UUID="CC52448F52447FE6" TYPE="ntfs" PARTUUID="a15007e4-02"
/dev/sdb3: LABEL="WinBackup" UUID="20429DB6429D90E0" TYPE="ntfs" PARTUUID="a15007e4-03"
/dev/sdb4: PTUUID="54295cf2-f319-49df-ac11-e0530fa17bcf" PTTYPE="gpt" PARTUUID="a15007e4-04"

The fstab and crypttab do not get changed or corrupted somehow, I've checked. So now I manually format the partition and enable swap:

$ sudo cryptsetup luksFormat /dev/sda2
...

$ sudo cryptsetup luksOpen /dev/sda2 sda2_crypt
...

$ sudo mkswap /dev/mapper/sda2_crypt
Setting up swapspace version 1, size = 4,7 GiB (4997509120 bytes)
no label, UUID=d570d09e-e9c5-47a7-9473-d59dde947d12

$ sudo blkid
/dev/mapper/sda3_crypt: UUID="73474220-1b0e-46bc-bba1-73fbbbc0a6f5" TYPE="ext4"
/dev/sda1: UUID="518c26ce-893a-49f4-ac53-1e2fac299a1e" TYPE="ext4" PARTUUID="dfa3c187-01"
/dev/sda3: UUID="2a8c24b1-eb27-4100-b94a-f7bf8680728b" TYPE="crypto_LUKS" PARTUUID="dfa3c187-03"
/dev/sdb1: LABEL="System Reserved" UUID="62D24140D24119A5" TYPE="ntfs" PARTUUID="a15007e4-01"
/dev/sdb2: UUID="CC52448F52447FE6" TYPE="ntfs" PARTUUID="a15007e4-02"
/dev/sdb3: LABEL="WinBackup" UUID="20429DB6429D90E0" TYPE="ntfs" PARTUUID="a15007e4-03"
/dev/sda2: UUID="5e035ee2-cbac-435c-b4e5-e70cd48196c6" TYPE="crypto_LUKS" PARTUUID="dfa3c187-02"
/dev/sda4: PTUUID="06ce4633-dc19-4578-a481-bcfe0f440142" PTTYPE="gpt" PARTUUID="dfa3c187-04"
/dev/sdb4: PTUUID="54295cf2-f319-49df-ac11-e0530fa17bcf" PTTYPE="gpt" PARTUUID="a15007e4-04"
/dev/mapper/sda2_crypt: UUID="d570d09e-e9c5-47a7-9473-d59dde947d12" TYPE="swap"

And replace the UUID for sda2 (5e03...) in crypttab, to this:

$ cat /etc/crypttab
sda2_crypt UUID=5e035ee2-cbac-435c-b4e5-e70cd48196c6 none luks,swap,discard
sda3_crypt UUID=2a8c24b1-eb27-4100-b94a-f7bf8680728b none luks,discard

And this will hold through the next reboot after which the partition will be decrypted using the same passphrase as for sda3 (root), and the swap will work fine, but running blkid will show no UUID on the partition, only PARTUUID. So I'm guessing on successful decryption and enabling swap something happens and the partition metadata or something gets nuked.

I have switched from using UUIDs to /dev paths in cryptsetup and now that problem is gone, however, the swap STILL won't work. Now I have this:

$ journalctl -b | grep -i crypt
May 13 16:40:04 localhost kernel: Key type encrypted registered
May 13 16:40:04 localhost systemd[1]: systemd 229 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN)
May 13 16:40:04 localhost systemd[1]: Created slice system-systemd\x2dcryptsetup.slice.
May 13 16:40:08 localhost systemd[1]: Starting Cryptography Setup for sda3_crypt...
May 13 16:40:08 localhost systemd[1]: Starting Cryptography Setup for sda2_crypt...
May 13 16:40:08 localhost systemd-cryptsetup[621]: Volume sda3_crypt already active.
May 13 16:40:08 localhost systemd[1]: Started Cryptography Setup for sda3_crypt.
May 13 16:40:09 localhost systemd-cryptsetup[629]: Set cipher aes, mode cbc-essiv:sha256, key size 256 bits for device /dev/sda2.
May 13 16:40:10 localhost systemd[1]: Found device /dev/mapper/sda2_crypt.
May 13 16:40:10 localhost systemd[1]: Activating swap /dev/mapper/sda2_crypt...
May 13 16:40:10 localhost mkswap[672]: mkswap: /dev/mapper/sda2_crypt: warning: wiping old swap signature.
May 13 16:40:10 localhost swapon[674]: swapon: /dev/mapper/sda2_crypt: swapon failed: Device or resource busy
May 13 16:40:10 localhost systemd[1]: dev-mapper-sda2_crypt.swap: Swap process exited, code=exited status=255
May 13 16:40:10 localhost systemd[1]: Failed to activate swap /dev/mapper/sda2_crypt.
May 13 16:40:10 localhost systemd[1]: dev-mapper-sda2_crypt.swap: Unit entered failed state.
May 13 16:40:10 localhost systemd[1]: Started Cryptography Setup for sda2_crypt.
May 13 16:40:10 localhost systemd[1]: Reached target Encrypted Volumes.

Running swapon /dev/mapper/sda2_crypt manually later enables the swap.

s/cryptsetup/crypttab in my last comment.

Launchpad Janitor (janitor) wrote :

[Expired for systemd (Ubuntu) because there has been no activity for 60 days.]

Changed in systemd (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers