“cryptsetup:错误:无法解析设备”与“cryptsetup:警告:在 /etc/crypttab 中找不到目标“sda3_crypt””

“cryptsetup:错误:无法解析设备”与“cryptsetup:警告:在 /etc/crypttab 中找不到目标“sda3_crypt””

设置后ubuntu 20.04 上的休眠并修改它以使其适用加密交换分区,我遇到几个问题:

首先,从休眠状态重新启动后,我收到“放弃等待挂起/恢复设备”和“找不到卷组”。幸运的是,之后我就可以正常启动系统了。

尽管如此,当再次执行上述网站的步骤时,我在执行时收到以下错误和警告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

请注意,该分区UUID=5834cf70-0919-4c53-98a6-355d69bbd6a4属于先前未加密的交换分区sda3。我用我所知道的每个配置文件(见下文)中的UUID加密分区之一替换了它。sda3_crypt

我希望通过以下打印输出所提供的问题能够得到解决。涉及的配置文件的内容(关于交换分区)是:

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. 猫/proc/交换

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

6. 自由-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 sudo swapon --all --verbose

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

8. 块基德 | grep 交换

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

9. lsblk | grep 交换

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

所有已安装设备的完整打印输出:

~/$ 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

所有配置文件中的所有行都以换行符结尾吗?

我在运行时遇到以下错误update-initramfs -c -k all

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

/etc/crypttab的是:

sda4_crypt UUID=[snip] none luks,discard

但是,行尾没有换行符。 /etc/crypttab由 POSIX shell 脚本(我编写的脚本)生成,并且在 POSIX shell 中创建带有尾随换行符的变量非常困难。

当我在行尾添加换行符后,错误消息消失了,看起来initramfs现在运行成功了。

相关内容