1

I am trying to encrypt swap file in 20.04 post-installation (i successfully conducted home dir encryption). I have a swap file created, with an UUID, and these are my

fstab:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda3 during installation
UUID=3b76b7a1-8e02-439b-982f-39f8954c4e6e /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
UUID=FEFC-8940  /boot/efi       vfat    umask=0077      0       1
UUID=684f3c6e-907a-4a35-95b4-7b6cde21440b none swap sw 0 0

crypttab (before starting):

# <target name> <source device>     <key file>  <options>

/dev/mapper is just control

blkid:

dev/sda3: UUID="3b76b7a1-8e02-439b-982f-39f8954c4e6e" TYPE="ext4" PARTUUID="6a8896ab-92bb-4bd7-a405-7650cca8d9e6"
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/loop6: TYPE="squashfs"
/dev/loop7: TYPE="squashfs"
/dev/sda1: UUID="FEFC-8940" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="305bb9b1-cde6-4fa5-9702-491a4dcd71f4"
/dev/loop8: TYPE="squashfs"
/dev/loop9: TYPE="squashfs"
/swapfile: UUID="684f3c6e-907a-4a35-95b4-7b6cde21440b" TYPE="swap"

following commands are run:

sudo swapoff -a
sudo /etc/init.d/cryptdisks start 
sudo swapon -a
sudo swapon -s

output:

/swapfile                               file        16777212    0   -2

/dev/mapper still just control. Now lets encrypt with: sudo ecryptfs-setup-swap!

output:

WARNING:
An encrypted swap is required to help ensure that encrypted files are not leaked to disk in an unencrypted format.

HOWEVER, THE SWAP ENCRYPTION CONFIGURATION PRODUCED BY THIS PROGRAM WILL BREAK HIBERNATE/RESUME ON THIS SYSTEM!

NOTE: Your suspend/resume capabilities will not be affected.

Do you want to proceed with encrypting your swap? [y/N]: y

INFO: Setting up swap: [/swapfile]
WARNING: Commented out your unencrypted swap from /etc/fstab
A dependency job for cryptsetup.target failed. See 'journalctl -xe' for details.

---journalctl -xe LOG---

https://pastebin.com/yqJZ9tQj

New crypttab is:

cryptswap1 /swapfile /dev/urandom swap,offset=1024,cipher=aes-xts-plain64

and new fstab is:

#UUID=684f3c6e-907a-4a35-95b4-7b6cde21440b none swap sw 0 0
/dev/mapper/cryptswap1 none swap sw 0 0

There is only one RED error in logs and it repeats itself:

-- The unit UNIT has successfully entered the 'dead' state.
Mai 23 20:51:32 icbosk-X556UV systemd[1]: dev-disk-by\x2duuid-684f3c6e\x2d907a\x2d4a35\x2d95b4\x2d7b6cde21440b.device: Job dev-disk-by\x2duui>
Mai 23 20:51:32 icbosk-X556UV systemd[1]: Timed out waiting for device /dev/disk/by-uuid/684f3c6e-907a-4a35-95b4-7b6cde21440b.
-- Subject: A start job for unit dev-disk-by\x2duuid-684f3c6e\x2d907a\x2d4a35\x2d95b4\x2d7b6cde21440b.device has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit dev-disk-by\x2duuid-684f3c6e\x2d907a\x2d4a35\x2d95b4\x2d7b6cde21440b.device has finished with a failure.
-- 
-- The job identifier is 1992 and the job result is timeout.

1 Answer 1

1

This issue is easily fixed by running sudo cryptdisks_start cryptswap1 when everything is orderly configured. Remember encrypted swap is ok if you dont use it extensively. It requires more CPU power if it is to be used as a regular swap.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .