我正在尝试设置几个LUKS加密分区,以便在启动时安装到新的ubuntu服务器上,该服务器在软件RAID之上安装了LVM.运行cryptsetup luksFormat后,LUKS标头在卷上清晰可见.在运行任何类型的mkfs之后,将覆盖标头(在没有LVM的情况下设置的其他系统上不会发生这种情况),并且cryptsetup将不再将该设备识别为LUKS设备.
# cryptsetup -y --cipher aes-cbc-essiv:sha256 --key-size 256 luksFormat /dev/dm-1 WARNING! ======== This will overwrite data on /dev/dm-1 irrevocably. Are you sure? (Type uppercase yes): YES Enter LUKS passphrase: Verify passphrase: # hexdump -C /dev/dm-1|head -n5 00000000 4c 55 4b 53 ba be 00 01 61 65 73 00 00 00 00 00 |LUKS....aes.....| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000020 00 00 00 00 00 00 00 00 63 62 63 2d 65 73 73 69 |........cbc-essi| 00000030 76 3a 73 68 61 32 35 36 00 00 00 00 00 00 00 00 |v:sha256........| 00000040 00 00 00 00 00 00 00 00 73 68 61 31 00 00 00 00 |........sha1....| # cryptsetup luksOpen /dev/dm-1 web2-var # mkfs.ext4 /dev/mapper/web2-var [..snip..] Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done # hexdump -C /dev/dm-1|head -n5 # cryptsetup luksClose /dev/mapper/web2-var 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000400 00 40 5d 00 00 88 74 01 66 a0 12 00 17 f2 6d 01 |.@]...t.f.....m.| 00000410 f5 3f 5d 00 00 00 00 00 02 00 00 00 02 00 00 00 |.?].............| 00000420 00 80 00 00 00 80 00 00 00 20 00 00 00 00 00 00 |......... ......| # cryptsetup luksOpen /dev/dm-1 web2-var Device /dev/dm-1 is not a valid LUKS device.
我也尝试过mkfs.ext2,结果相同.基于我在Debian和Ubuntu(但不是LVM或Ubuntu 12.04)上成功完成的设置,很难理解为什么会失败.
解决方法
如果设备确实名为/ dev / web2 / var,那么这意味着您使用的是LVM,加密卷是web2卷组中的var逻辑卷.这意味着已经有一个名为/ dev / mapper / web2-var的设备,并且当你告诉它解锁卷时,cryptsetup可能不会覆盖它.因此,您要格式化原始卷,而不是解密卷.
我不知道为什么你没有从cryptsetup收到错误.您可能想要在其上提交错误.或者至少检查它是否自动将未锁定的设备重命名为/ dev / mapper / web2-var2等.
在此期间,为解密的卷提供一个新名称.尝试
cryptsetup luksOpen /dev/dm-1 web2-var_crypt