我今天更新了,然后重启。结果是找不到卷组,它退出到 BusyBox。
我试过:
从 busybox 中发出“vgchange -ay”->什么也没做。
使用旧内核启动->结果相同。
然后我从一张现场 CD 开始。
我找到了这个网页:从无法启动的 Ubuntu 加密 LVM 根分区中恢复,但我的/etc/crypttab
却是空的。
这里您可以看到文件系统的结构:
两个 SSD sda 和 sdb 在 3ware 控制器上创建 raid 1 阵列 sdc。然后在 2x 8TB HDD 上启动软 raid 1(BIOS 可识别,但无法从实时 CD 访问(除非我知道如何访问),即使 SSD 上的加密已打开)。
所以我想...首先...我需要修复在启动期间可以找到的卷组。
如果我首先解锁加密并sudo vgchange -ay
在实时 CD 上运行,那么它看起来很有希望:
2 logical volume(s) in volume group "hal9999-vg" now active
但是重新启动后仍然找不到卷组。
我读到该问题与 LVM 和 initramfs 有关,但我不想随意摆弄我的文件系统,以免陷入更大的麻烦。
与此同时,我尝试这个答案它淹没了我的 crypttab,但update-initramfs -u -k all
失败了:
update-initramfs: Generating /boot/initrd.img-5.4.0-40-generic
cryptsetup: WARNING: target 'luks-524c1ad6-fabe-4f32-9bb0-c8db1286b262' not
found in /etc/crypttab
W: /sbin/fsck.crypto_LUKS doesn't exist, can't install to initramfs
毕竟这是目前的状态:
输出lsblk -fs
:
NAME FSTYPE LABEL UUID MOUNTPOINT
loop0 squashfs /rofs
sda linux_raid_member hal9999:0 853e3329-6076-8398-e0d8-19149c7d0d64
sdb linux_raid_member hal9999:0 853e3329-6076-8398-e0d8-19149c7d0d64
sdc1 vfat 94B1-AF12
└─sdc
sdc2 ext4 bbb39977-bf4a-4d8b-b524-7c29a85471d0 /mnt/boot
└─sdc
sdd1 vfat XUBUNTU 18_ 849C-7AF8 /cdrom
└─sdd
hal9999--vg-root ext4 17c06541-b952-41a2-b28d-b37e49771625 /mnt
└─luks-524c1ad6-fabe-4f32-9bb0-c8db1286b262
LVM2_member JK4UPj-KdoV-yFe5-XBZW-cHFP-JCbV-JsLjPq
└─sdc3 crypto_LUKS 524c1ad6-fabe-4f32-9bb0-c8db1286b262
└─sdc
hal9999--vg-swap_1 swap cd5a6a21-dea3-46a9-a524-e43de19c0587
└─luks-524c1ad6-fabe-4f32-9bb0-c8db1286b262
LVM2_member JK4UPj-KdoV-yFe5-XBZW-cHFP-JCbV-JsLjPq
└─sdc3 crypto_LUKS 524c1ad6-fabe-4f32-9bb0-c8db1286b262
└─sdc
/etc/crypttab
:
sdc3_crypt UUID=524c1ad6-fabe-4f32-9bb0-c8db1286b262 none luks,discard
data /dev/md0 /root/drive_key luks
/etc/cryptsetup-initramfs/conf-hook
:
#
# Configuration file for the cryptroot initramfs hook.
#
#
# KEYFILE_PATTERN: ...
#
# The value of this variable is interpreted as a shell pattern.
# Matching key files from the crypttab(5) are included in the initramfs
# image. The associated devices can then be unlocked without manual
# intervention. (For instance if /etc/crypttab lists two key files
# /etc/keys/{root,swap}.key, you can set KEYFILE_PATTERN="/etc/keys/*.key"
# to add them to the initrd.)
#
# If KEYFILE_PATTERN if null or unset (default) then no key file is
# copied to the initramfs image.
#
# Note that the glob(7) is not expanded for crypttab(5) entries with a
# 'keyscript=' option. In that case, the field is not treated as a file
# name but given as argument to the keyscript.
#
# WARNING: If the initramfs image is to include private key material,
# you'll want to create it with a restrictive umask in order to keep
# non-privileged users at bay. For instance, set UMASK=0077 in
# /etc/initramfs-tools/initramfs.conf
#
#KEYFILE_PATTERN=
CRYPTSETUP=Y
/etc/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>
UUID=524c1ad6-fabe-4f32-9bb0-c8db1286b262 / ext4 errors=remount-ro 0 1
#/dev/mapper/hal9999--vg-root / ext4 errors=remount-ro 0 1
# /boot was on /dev/sdc2 during installation
UUID=bbb39977-bf4a-4d8b-b524-7c29a85471d0 /boot ext4 defaults 0 2
# /boot/efi was on /dev/sdc1 during installation
UUID=94B1-AF12 /boot/efi vfat umask=0077 0 1
/dev/mapper/hal9999--vg-swap_1 none swap sw 0 0
#/dev/md0 /mnt/md0 ext4 defaults,nofail,discard 0 0
/dev/mapper/data /mnt/data ext4 defaults 0 2
看起来诊断“Ubuntu 在上次更新时意外删除了 lvm 和 cryptsetup”可能是这种情况。
我运行了以下命令:
root@xubuntu:/home/xubuntu# mount /dev/mapper/sdc2 /mnt/boot
mount: /mnt/boot: special device /dev/mapper/sdc2 does not exist.
root@xubuntu:/home/xubuntu# mount /dev/sdc2 /mnt/boot
root@xubuntu:/home/xubuntu# mount -t proc proc /mnt/proc
root@xubuntu:/home/xubuntu# mount -o bind /dev /mnt/dev
root@xubuntu:/home/xubuntu# mount -o bind /sys /mnt/sys
root@xubuntu:/home/xubuntu# chroot /mnt
...并改为/etc/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>
#UUID=524c1ad6-fabe-4f32-9bb0-c8db1286b262 / ext4 errors=remount-ro 0 1
/dev/mapper/hal9999--vg-root / ext4 errors=remount-ro 0 1
# /boot was on /dev/sdc2 during installation
UUID=bbb39977-bf4a-4d8b-b524-7c29a85471d0 /boot ext4 defaults 0 2
# /boot/efi was on /dev/sdc1 during installation
UUID=94B1-AF12 /boot/efi vfat umask=0077 0 1
/dev/mapper/hal9999--vg-swap_1 none swap sw 0 0
#/dev/md0 /mnt/md0 ext4 defaults,nofail,discard 0 0
/dev/mapper/data /mnt/data ext4 defaults 0 2
现在我收到此错误update-initramfs -c -k all
:
cryptsetup: WARNING: target 'luks-524c1ad6-fabe-4f32-9bb0-c8db1286b262' not
found in /etc/crypttab
update-initramfs: Generating /boot/initrd.img-5.4.0-39-generic
cryptsetup: WARNING: target 'luks-524c1ad6-fabe-4f32-9bb0-c8db1286b262' not
found in /etc/crypttab
update-initramfs: Generating /boot/initrd.img-5.4.0-40-generic
cryptsetup: WARNING: target 'luks-524c1ad6-fabe-4f32-9bb0-c8db1286b262' not
found in /etc/crypttab
新输出:
xubuntu@xubuntu:~$ lsblk --fs
NAME FSTYPE LABEL UUID MOUNTPOINT
loop0 squashfs /rofs
sda linux_raid_member hal9999:0 853e3329-6076-8398-e0d8-19149c7d0d64
sdb linux_raid_member hal9999:0 853e3329-6076-8398-e0d8-19149c7d0d64
sdc
├─sdc1 vfat 94B1-AF12
├─sdc2 ext4 bbb39977-bf4a-4d8b-b524-7c29a85471d0 /mnt/boot
└─sdc3 crypto_LUKS 524c1ad6-fabe-4f32-9bb0-c8db1286b262
└─sdc3_crypt LVM2_member JK4UPj-KdoV-yFe5-XBZW-cHFP-JCbV-JsLjPq
├─hal9999--vg-root
│ ext4 17c06541-b952-41a2-b28d-b37e49771625 /mnt
└─hal9999--vg-swap_1
swap cd5a6a21-dea3-46a9-a524-e43de19c0587
sdd
└─sdd1 vfat XUBUNTU 18_ 849C-7AF8 /cdrom
新的错误:结果update-initramfs -c -k all
:
update-initramfs: Generating /boot/initrd.img-5.3.0-59-generic
cryptsetup: ERROR: Couldn't resolve device
UUID=luks-524c1ad6-fabe-4f32-9bb0-c8db1286b262
update-initramfs: Generating /boot/initrd.img-5.4.0-39-generic
cryptsetup: ERROR: Couldn't resolve device
UUID=luks-524c1ad6-fabe-4f32-9bb0-c8db1286b262
update-initramfs: Generating /boot/initrd.img-5.4.0-40-generic
cryptsetup: ERROR: Couldn't resolve device
UUID=luks-524c1ad6-fabe-4f32-9bb0-c8db1286b262
答案1
跑步:
dmsetup -u sdc3_crypt <UUID of crypt partition>
更改 fstab 以便
/dev/mapper/>rootpartition
(见下文)命名。删除
luks
crypttab 中 UUID 之前的前缀(见下文)。
新的工作 fstab:
# <file system> <mount point> <type> <options> <dump> <pass>
#UUID=524c1ad6-fabe-4f32-9bb0-c8db1286b262 / ext4 errors=remount-ro 0 1
# crypt /dev/sdc3 none luks,initramfs
/dev/mapper/hal9999--vg-root / ext4 errors=remount-ro 0 1
# /boot was on /dev/sdc2 during installation
UUID=bbb39977-bf4a-4d8b-b524-7c29a85471d0 /boot ext4 defaults 0 2
# /boot/efi was on /dev/sdc1 during installation
UUID=94B1-AF12 /boot/efi vfat umask=0077 0 1
/dev/mapper/hal9999--vg-swap_1 none swap sw 0 0
#/dev/md0 /mnt/md0 ext4 defaults,nofail,discard 0 0
/dev/mapper/data /mnt/data ext4 defaults 0 2
新工作的 crypttab:
# sdc3_crypt UUID=524c1ad6-fabe-4f32-9bb0-c8db1286b262 none luks,discard
#
# luks-524c1ad6-fabe-4f32-9bb0-c8db1286b262 UUID=luks-524c1ad6-fabe-4f32-9bb0-c8db1286b262 none luk>
# UUID=luks-524c1ad6-fabe-4f32-9bb0-c8db1286b262 none luks,discard
sdc3_crypt UUID=524c1ad6-fabe-4f32-9bb0-c8db1286b262 none luks,discard
#sdc3_crypt UUID=JK4UPj-KdoV-yFe5-XBZW-cHFP-JCbV-JsLjPq none luks,discard
data /dev/md0 /root/drive_key luks
现在update-initramfs -c -k
所有操作均顺利完成,没有任何错误,因此重新启动并找到了文件系统。