我有一个朋友的 Debian 机器上的 LUKS/cryptsetup 加密磁盘,它无法启动。我正尝试使用 USB 外壳将其安装到另一台 Debian 机器上,以恢复数据或获取有关问题的线索。我是一个经验丰富的 Linux 命令行用户,但对 LUKS 和 LVM 完全是新手。
自动挂载不起作用(它接受密码但随后提示文件系统不可用,并且无法挂载)。
因此我尝试从命令行安装它。
root@somepc:/dev/mapper# fdisk -l | grep sdb
Disk /dev/sdb: 149.1 GiB, 160041885696 bytes, 312581808 sectors
/dev/sdb1 2048 999423 997376 487M 83 Linux
/dev/sdb2 1001470 312580095 311578626 148.6G 5 Extended
/dev/sdb5 1001472 312580095 311578624 148.6G 83 Linux
root@somepc:~# cryptsetup luksOpen /dev/sdb5 foo
Enter passphrase for /dev/sdb5: [Passphrase accepted]
root@somepc:~# vgdisplay
--- Volume group ---
VG Name ubuntu-mate-vg21
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 9
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 148.57 GiB
PE Size 4.00 MiB
Total PE 38033
Alloc PE / Size 38027 / 148.54 GiB
Free PE / Size 6 / 24.00 MiB
VG UUID y7TB6e-b6hT-0Fpr-wXAY-6DwW-1Vyw-2bolpJ
--- Volume group ---
[ details of system disk ]
此时我意识到我的朋友曾尝试使用 Ubuntu Mate 机器恢复它。以下内容表明他一定修改了分区...根据“LV 创建主机,时间”判断 - 他说他在 GParted 中查看了它,GParted 可能对它做了一些操作。
我们就像是盲人引领盲人……
root@somepc:~# lvdisplay /dev/ubuntu-mate-vg21
--- Logical volume ---
LV Path /dev/ubuntu-mate-vg21/root
LV Name root
VG Name ubuntu-mate-vg21
LV UUID wOnyHp-WXox-QatY-mQEy-Esuz-ADcP-TzVEFh
LV Write Access read/write
LV Creation host, time ubuntu-mate, 2017-04-08 06:50:00 +0300
LV Status NOT available
LV Size 140.87 GiB
Current LE 36062
Segments 1
Allocation inherit
Read ahead sectors auto
--- Logical volume ---
LV Path /dev/ubuntu-mate-vg21/swap_1
LV Name swap_1
VG Name ubuntu-mate-vg21
LV UUID WapYkq-O3AP-r0x9-3bBW-KcWD-yCNC-mw8Gq2
LV Write Access read/write
LV Creation host, time ubuntu-mate, 2017-04-08 06:50:01 +0300
LV Status NOT available
LV Size 7.68 GiB
Current LE 1965
Segments 1
Allocation inherit
Read ahead sectors auto
无论如何,继续前进。
root@somepc:~# vgchange -ay ubuntu-mate-vg21
2 logical volume(s) in volume group "ubuntu-mate-vg21" now active
root@somepc:~# mount /dev/ubuntu-mate-vg21/root /mnt/test
mount: wrong fs type, bad option, bad superblock on /dev/mapper/ubuntu--mate--vg21-root,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
所以我谷歌搜索了“坏超级块”,然后
root@somepc:~# fsck /dev/ubuntu-mate-vg21/root
fsck from util-linux 2.25.2
e2fsck 1.42.12 (29-Aug-2014)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/mapper/ubuntu--mate--vg21-root
The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem. If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
or
e2fsck -b 32768 <device>
root@somepc:~# mke2fs -n /dev/ubuntu-mate-vg21/root
mke2fs 1.42.12 (29-Aug-2014)
Creating filesystem with 36927488 4k blocks and 9232384 inodes
Filesystem UUID: 484f5abf-3fee-42a7-af1c-22f9bdde8976
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
然后我尝试了e2fsck -b <BLOCKNUMBER> /dev/ubuntu-mate-vg21/root
每个块号,但每次都出现与上述相同的错误。
后来我读到你不需要也不应该在逻辑卷上运行 fsck,或者其他什么,所以我希望我没有让情况变得更糟。
我觉得在放弃这张磁盘之前我肯定还能做点什么,但我真的很难找到答案。也许我只需要参考一些文档。
谢谢