14

After setting up hibernation on ubuntu 20.04 and modifying it that it works for encrypted swap partitions, I'm getting several issues:

First, after rebooting from hibernation, I got "Gave up waiting for suspend/resume device" along with "Volume group luks not found". Fortunately, I could boot the system normally afterwards.

Still, when going through the steps of the aforementioned websites again, I get the following errors and warnings when executing sudo update-initramfs -c -k all:

update-initramfs: Generating /boot/initrd.img-5.4.0-56-generic
cryptsetup: ERROR: Couldn't resolve device 
    /dev/disk/by-uuid/5834cf70-0919-4c53-98a6-355d69bbd6a4
cryptsetup: ERROR: Couldn't resolve device 
    UUID=5834cf70-0919-4c53-98a6-355d69bbd6a4
cryptsetup: WARNING: target 'sda3_crypt' not found in /etc/crypttab
update-initramfs: Generating /boot/initrd.img-5.4.0-58-generic
cryptsetup: ERROR: Couldn't resolve device 
    /dev/disk/by-uuid/5834cf70-0919-4c53-98a6-355d69bbd6a4
cryptsetup: ERROR: Couldn't resolve device 
    UUID=5834cf70-0919-4c53-98a6-355d69bbd6a4
cryptsetup: WARNING: target 'sda3_crypt' not found in /etc/crypttab

Note that the UUID=5834cf70-0919-4c53-98a6-355d69bbd6a4 belonged to the previously non-encrypted swap partition sda3. I replaced this UUID with the one of the encrypted partition sda3_crypt in every configuration file (see below) I know of.

I hope with the following printouts provided the problems can be resolved. The contents of the configuration files involved (concerning the swap partition) are:

1. /etc/fstab

/dev/mapper/sda3_crypt none swap sw 0 0

2. /etc/initramfs-tools/conf.d/resume

RESUME=UUID=1e1793ab-315d-4797-a4df-ba5675f4c177

3. /etc/crypttab

sda3_crypt /dev/sda3 /dev/urandom cipher=aes-xts-plain64,size=256,swap,discard

4. /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="cryptdevice=UUID=abcb93a9-b73a-4e57-9f78-91b292b6bfb2:luks-abcb93a9-b73a-4e57-9f78-91b292b6bfb2 root=/dev/mapper/luks-abcb93a9-b73a-4e57-9f78-91b292b6bfb2 resume=UUID=1e1793ab-315d-4797-a4df-ba5675f4c177"

5. cat /proc/swaps

Filename                                Type            Size    Used    Priority
/dev/dm-1                               partition       16561148        55296   -2

6. free -mh

              total        used        free      shared  buff/cache   available
Mem:          7.6Gi       3.6Gi       139Mi       545Mi       3.9Gi       3.2Gi
Swap:          15Gi        54Mi        15Gi

7. sudo swapon --all --verbose

swapon: /dev/mapper/sda3_crypt: already active -- ignored

8. blkid | grep swap

/dev/mapper/sda3_crypt: UUID="1e1793ab-315d-4797-a4df-ba5675f4c177" TYPE="swap"

9. lsblk | grep SWAP

`-sda3_crypt                                253:1    0  15.8G  0 crypt [SWAP]

The entire printouts of all mounted devices:

~/$ blkid
/dev/mapper/luks-abcb93a9-b73a-4e57-9f78-91b292b6bfb2: UUID="3dad5211-99f3-4513-bbcc-de820c2dbe8b" TYPE="ext4"
/dev/sda1: UUID="11F5-FCE6" TYPE="vfat" PARTUUID="59397319-bfe7-1841-b259-c157e97b19bd"
/dev/sda2: UUID="abcb93a9-b73a-4e57-9f78-91b292b6bfb2" TYPE="crypto_LUKS" PARTUUID="11c68a93-8cdf-e04f-ad0d-d4c1bfce2796"
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/mapper/sda3_crypt: UUID="1e1793ab-315d-4797-a4df-ba5675f4c177" TYPE="swap"

~/$ lsblk
NAME                                          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
loop0                                           7:0    0  55.4M  1 loop  /snap/core18/1932
loop1                                           7:1    0  55.4M  1 loop  /snap/core18/1944
loop2                                           7:2    0  31.1M  1 loop  /snap/snapd/10238
loop3                                           7:3    0  31.1M  1 loop  /snap/snapd/10492
sda                                             8:0    0 232.9G  0 disk  
|-sda1                                          8:1    0   300M  0 part  /boot/efi
|-sda2                                          8:2    0 216.8G  0 part  
| `-luks-abcb93a9-b73a-4e57-9f78-91b292b6bfb2 253:0    0 216.8G  0 crypt /
`-sda3                                          8:3    0  15.8G  0 part  
  `-sda3_crypt                                253:1    0  15.8G  0 crypt [SWAP]

1 Answer 1

2

Do all the lines in all your config files end with the newline character?

I encountered the below error while running update-initramfs -c -k all:

cryptsetup: WARNING: target 'sda4_crypt' not found in /etc/crypttab

My /etc/crypttab was:

sda4_crypt UUID=[snip] none luks,discard

However, there was no newline character at the end of the line. /etc/crypttab was generated by a POSIX shell script (a script that I wrote), and it is hideously difficult create variables with trailing newline characters in POSIX shell.

After I added a newline character at the end of the line, the error message went away, and it appears that initramfs is now running successfully.

6
  • > hideously difficult - perhaps: echo "sda4_crypt UUID=[$uuid] none luks,discard" or printf "%s%d_crypt UUID=[%s] none luks,discard\n" "$disk" "$part" "$uuid"
    – D McKeon
    Commented Mar 1, 2021 at 0:40
  • I only want to rewrite the file if it needs to change. So... I store the desired text in a variable (including the trailing newline). I read the actual text from the file (including the trailing newline, if one exists). Then, I only update (rewrite) the file if the desired and actual text differ. In POSIX shell, creating and/or preserving trailing newlines is far more work than it should be.
    – mpb
    Commented Mar 2, 2021 at 7:26
  • How can I check whether all lines in these textfiles have an endline character?
    – Andreas L.
    Commented Mar 2, 2021 at 18:07
  • I can tell by examining the files in my text editor. I use emacs and jed. You could also run cat filename ; echo xxx in a terminal, and see if the xxx appears at the beginning versus the end of the line.
    – mpb
    Commented Mar 3, 2021 at 20:15
  • cat -vte filename ; echo xxx would show any control chars, tabs, and end-of-line.
    – D McKeon
    Commented Mar 14, 2021 at 21:11

You must log in to answer this question.

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