带有LVM的LUKS,在重新引导后mount不是持久的

我创build了一个逻辑卷,并使用luksencryption它。 但是,当重新启动服务器。 我得到一个错误消息(下面),因此我将不得不input根传递并禁用/ etc / fstab条目。 因此,在使用LUKS重新启动的过程中,LUKS分区的挂载不是持久的。 我在RHEL6上安装了这个设置,想知道我可能会丢失什么。 我想让LV在重新启动时挂载。 后来我想用UUID代替设备名称来代替它。

重新启动时出现错误消息:“为维护提供root密码(或键入Control-D以继续):”

这是从一开始的步骤:

[root@rhel6 ~]# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created [root@rhel6 ~]# vgcreate vg01 /dev/sdb Volume group "vg01" successfully created [root@rhel6 ~]# lvcreate --size 500M -n lvol1 vg01 Logical volume "lvol1" created [root@rhel6 ~]# lvdisplay --- Logical volume --- LV Name /dev/vg01/lvol1 VG Name vg01 LV UUID nX9DDe-ctqG-XCgO-2wcx-ddy4-i91Y-rZ5u91 LV Write Access read/write LV Status available # open 0 LV Size 500.00 MiB Current LE 125 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 [root@rhel6 ~]# cryptsetup luksFormat /dev/vg01/lvol1 WARNING! ======== This will overwrite data on /dev/vg01/lvol1 irrevocably. Are you sure? (Type uppercase yes): YES Enter LUKS passphrase: Verify passphrase: [root@rhel6 ~]# mkdir /house [root@rhel6 ~]# cryptsetup luksOpen /dev/vg01/lvol1 house Enter passphrase for /dev/vg01/lvol1: [root@rhel6 ~]# mkfs.ext4 /dev/mapper/house mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 127512 inodes, 509952 blocks 25497 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67633152 63 block groups 8192 blocks per group, 8192 fragments per group 2024 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 21 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@rhel6 ~]# mount -t ext4 /dev/mapper/house /house PS: HERE I have successfully mounted: [root@rhel6 ~]# ls /house/ lost+found [root@rhel6 ~]# vim /etc/fstab -> as follow /dev/mapper/house /house ext4 defaults 1 2 [root@rhel6 ~]# vim /etc/crypttab -> entry as follows house /dev/vg01/lvol1 password [root@rhel6 ~]# mount -o remount /house [root@rhel6 ~]# ls /house/ lost+found [root@rhel6 ~]# umount /house/ [root@rhel6 ~]# mount -a -> SUCCESSFUL AGAIN [root@rhel6 ~]# ls /house/ lost+found 

请让我知道,如果我在这里失去了什么。

提前致谢。

这是我find的解决scheme,我只是分享它为了他人的利益。

只是在/ etc / crypttab中input密码对我来说不起作用 – 而是我用以下命令创build了一个随机密钥,用于encryption密码 – 但是,密钥仍然不安全地存储在/root/pass.key下。

dd if=/dev/random of=/root/pass.key bs=32 count=1

cryptsetup luksAddKey /dev/vg01/lvol1 /root/pass.key

然后我使用vim编辑/ etc / crypttab并添encryption钥文件的path。