[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [solved] What is the correct way to set encrypted swap with systemd?



On 03/28/2015 08:32 AM, Sven Hartge wrote:
> ~Stack~ <i.am.stack@gmail.com> wrote:
> 
>> Remember back a few months ago when systemd wouldn't stop fsck'ing my
>> swap partition?
> 
> Why would systemd fsck the swap? swap does not need fscking.

I have no idea. But, if I disable the swap partition the system boots
just fine. If I enable it, fsck tries to run and the partition is
complains about is the swap partition. I have no idea why systemd.fsck
does this. :-/

[snip]
> I have the same setup on Debian Sid with systemd, just like you:
> 
> ,----[ /etc/crypttab
> | # <target name> <source device>         <key file>      <options>
> | cswap   /dev/disk/by-id/md-uuid-a805edd5:bcfd4c98:ce747c2c:77d42131     /dev/urandom    swap,cipher=aes-cbc-essiv:sha256,size=256
> `----

Thank you!! I think I just found out what my note "systemd.fsck doesn't
like UUID's" meant! I was assuming it was in the /etc/fstab or
somewhere, but when I noticed you have the /dev location of your disk
and I have a UUID in the /etc/crypttab I decided to give it a try.

$ grep swap /etc/crypttab
# causes systemd to fsck swap
#sda3_crypt UUID=ef2496cd-ca4d-43aa-8c90-dba084029f6e /dev/urandom
cipher=aes-xts-plain64,size=256,swap
# systemd doesn't fsck swap
sda3_crypt /dev/sda3 /dev/urandom cipher=aes-xts-plain64,size=256,swap

I reverted all of my changes that I took notes on and
bada-bing-bada-boom! It works now!

Out of curiosity (and because I have a sacrificial VM with various
snapshots I can easily reset to), I setup a encrypted swap on a Ubuntu
15.04 alpha (pre-systemd) with my previous method. Swap worked
perfectly. I 'apt-get update'd 15.04 and installed the systemd package
(and a lot of "dependencies" o_O). On the first boot systemd.fsck had
issues with swap and didn't mount it. I changed it to the disk instead
of UUID and rebooted. Works!! So it isn't just systemd in Debian either.

At least I now know in the future not to use UUID for swap in /etc/crypttab!

Sometimes it seems that the most painful and frustrating problems have
the most trivial solutions. :-D

Thanks!
~Stack~

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: