=== modified file 'src/utils/ecryptfs-setup-swap' --- src/utils/ecryptfs-setup-swap 2016-07-13 05:02:30 +0000 +++ src/utils/ecryptfs-setup-swap 2017-03-06 17:40:30 +0000 @@ -150,7 +150,7 @@ info `gettext "Setting up swap:"` "[$swap]" uuid=$(blkid -o value -s UUID $swap) # /etc/fstab might use a symlink like /dev/mapper/ubuntu--vg-swap_1 - links=$(for d in $(udevadm info --query=symlink -n $swap); do echo /dev/$d; done) + [ -f $swap ] || links=$(for d in $(udevadm info --query=symlink -n $swap); do echo /dev/$d; done) for target in "UUID=$uuid" $swap $links; do if [ -n "$target" ] && grep -qs "^$target\s\+" /etc/fstab; then sed -i "s:^$target\s\+:\#$target :" /etc/fstab @@ -193,8 +193,11 @@ # Add crypttab entry # Use /dev/urandom, since this is not a long lived key (generated each boot), # and so that we don't block booting while waiting for entropy - echo "cryptswap$i UUID=$uuid /dev/urandom swap,offset=1024,cipher=aes-xts-plain64" >> /etc/crypttab - + if [ -f $swap ]; then # swapfile + echo "cryptswap$i $swap /dev/urandom swap,offset=1024,cipher=aes-xts-plain64" >> /etc/crypttab + else # partition + echo "cryptswap$i UUID=$uuid /dev/urandom swap,offset=1024,cipher=aes-xts-plain64" >> /etc/crypttab + fi # Add fstab entry echo "/dev/mapper/cryptswap$i none swap sw 0 0" >> /etc/fstab done @@ -204,7 +207,9 @@ swapoff -a # Restart cryptdisks - /etc/init.d/cryptdisks restart + #/etc/init.d/cryptdisks restart + # the above script does nothing, the following is the right command: + systemctl restart cryptsetup.target # Turn the swap on swapon -a