我正在尝试保存一个以前存储在小型 USB 盘上的系统中的数据,但我怀疑是硬件故障。系统从挂起状态恢复时,根文件系统处于只读状态,我没有意识到系统即将死机,我应该尝试保存一些数据,而是选择快速重启,但此后无法以任何方式恢复。
这是 Ubuntu 18.04,在安装时选择了加密的根文件系统,所以我猜那是 LUKS。如果我现在尝试启动它,我会看到紫色屏幕,然后是错误消息,然后我会收到提示(initramfs)
。我尝试按照以下方法手动对文件系统进行 fsck此处的说明但不断收到以下类型的 I/O 错误,
Buffer I/O error on dev dm-1, logical block 4, lost async page page write
和
print_req_error: critical target error, dev sda, sector 9896192 flags 801
。
结尾是
fsck.ext4: unable to set superblock flags on /dev/mapper/ubuntu--vg-root
,
并告诉我文件系统仍然有错误。我尝试指定备份超级块,但没有成功。
我现在尝试将存储棒放入健康的系统中,解密并安装它,看看是否还能保存一些东西。插入存储棒时,系统提示我输入密钥,显然它解密了它,请参阅系统日志:
Dec 21 03:38:42 X1 kernel: [36919.500937] usb 2-1: new SuperSpeed Gen 1 USB device number 3 using xhci_hcd
Dec 21 03:38:42 X1 kernel: [36919.521737] usb 2-1: New USB device found, idVendor=0781, idProduct=5583, bcdDevice= 1.00
Dec 21 03:38:42 X1 kernel: [36919.521742] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Dec 21 03:38:42 X1 kernel: [36919.521745] usb 2-1: Product: Ultra Fit
Dec 21 03:38:42 X1 kernel: [36919.521748] usb 2-1: Manufacturer: SanDisk
Dec 21 03:38:42 X1 kernel: [36919.521751] usb 2-1: SerialNumber: 4C530001210812112290
Dec 21 03:38:42 X1 kernel: [36919.523118] usb-storage 2-1:1.0: USB Mass Storage device detected
Dec 21 03:38:42 X1 kernel: [36919.523697] scsi host1: usb-storage 2-1:1.0
Dec 21 03:38:42 X1 mtp-probe: checking bus 2, device 3: "/sys/devices/pci0000:00/0000:00:14.0/usb2/2-1"
Dec 21 03:38:42 X1 mtp-probe: bus: 2, device: 3 was not an MTP device
Dec 21 03:38:42 X1 upowerd[1354]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1:1.0
Dec 21 03:38:42 X1 upowerd[1354]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-1
Dec 21 03:38:43 X1 kernel: [36920.553722] scsi 1:0:0:0: Direct-Access SanDisk Ultra Fit 1.00 PQ: 0 ANSI: 6
Dec 21 03:38:43 X1 kernel: [36920.554585] sd 1:0:0:0: Attached scsi generic sg1 type 0
Dec 21 03:38:43 X1 kernel: [36920.554754] sd 1:0:0:0: [sdb] 489160704 512-byte logical blocks: (250 GB/233 GiB)
Dec 21 03:38:43 X1 kernel: [36920.555633] sd 1:0:0:0: [sdb] Write Protect is on
Dec 21 03:38:43 X1 kernel: [36920.555641] sd 1:0:0:0: [sdb] Mode Sense: 43 00 80 00
Dec 21 03:38:43 X1 kernel: [36920.555952] sd 1:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Dec 21 03:38:43 X1 kernel: [36920.566040] sdb: sdb1 sdb2 < sdb5 >
Dec 21 03:38:43 X1 kernel: [36920.568791] sd 1:0:0:0: [sdb] Attached SCSI removable disk
Dec 21 03:38:43 X1 kernel: [36920.961099] EXT4-fs (sdb1): INFO: recovery required on readonly filesystem
Dec 21 03:38:43 X1 kernel: [36920.961100] EXT4-fs (sdb1): write access unavailable, cannot proceed (try mounting with noload)
Dec 21 03:38:43 X1 gnome-shell[1828]: Unable to mount volume 767 MB Volume: Gio.IOErrorEnum: Error mounting /dev/sdb1 at /media/peter/0b776e27-d039-4fc5-ad20-462e5e36e031: cannot mount /dev/sdb1 read-only
Dec 21 03:38:50 X1 gnome-shell[1828]: Unable to mount volume 250 GB Encrypted: Gio.IOErrorEnum: Operation was cancelled
Dec 21 03:38:50 X1 udisksd[1004]: Unlocked LUKS device /dev/sdb5 as /dev/dm-3
现在
$ sudo fsck /dev/dm-3 -y
fsck from util-linux 2.31.1
没有别的了。不知道这是好消息还是坏消息,或者我可能走错了路。只是尝试安装它,我得到了unknown filesystem type 'LVM2_member'.
以下内容也没有帮助:
$ udisksctl mount -b /dev/dm-3
Object /org/freedesktop/UDisks2/block_devices/dm_2d3 is not a mountable filesystem.
现在我仍然不太了解 LVM 和 LUKS 的工作原理,也不知道这根棒子坏得有多严重。我下一步该怎么做?
编辑:我正在再次尝试进入磁盘,将其插入健康的系统。系统要求我输入密码,系统显然已解密。
Jan 4 13:15:59 X1 kernel: [258125.811027] usb 2-2: new SuperSpeed Gen 1 USB device number 6 using xhci_hcd
Jan 4 13:15:59 X1 kernel: [258125.835919] usb 2-2: New USB device found, idVendor=0781, idProduct=5583, bcdDevice= 1.00
Jan 4 13:15:59 X1 kernel: [258125.835924] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jan 4 13:15:59 X1 kernel: [258125.835927] usb 2-2: Product: Ultra Fit
Jan 4 13:15:59 X1 kernel: [258125.835930] usb 2-2: Manufacturer: SanDisk
Jan 4 13:15:59 X1 kernel: [258125.835933] usb 2-2: SerialNumber: 4C530001210812112290
Jan 4 13:15:59 X1 kernel: [258125.837229] usb-storage 2-2:1.0: USB Mass Storage device detected
Jan 4 13:15:59 X1 kernel: [258125.837738] scsi host1: usb-storage 2-2:1.0
Jan 4 13:15:59 X1 mtp-probe: checking bus 2, device 6: "/sys/devices/pci0000:00/0000:00:14.0/usb2/2-2"
Jan 4 13:15:59 X1 mtp-probe: bus: 2, device: 6 was not an MTP device
Jan 4 13:15:59 X1 upowerd[1314]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0
Jan 4 13:15:59 X1 upowerd[1314]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-2
Jan 4 13:16:00 X1 kernel: [258126.856090] scsi 1:0:0:0: Direct-Access SanDisk Ultra Fit 1.00 PQ: 0 ANSI: 6
Jan 4 13:16:00 X1 kernel: [258126.856856] sd 1:0:0:0: Attached scsi generic sg1 type 0
Jan 4 13:16:00 X1 kernel: [258126.856963] sd 1:0:0:0: [sdb] 489160704 512-byte logical blocks: (250 GB/233 GiB)
Jan 4 13:16:00 X1 kernel: [258126.857870] sd 1:0:0:0: [sdb] Write Protect is on
Jan 4 13:16:00 X1 kernel: [258126.857875] sd 1:0:0:0: [sdb] Mode Sense: 43 00 80 00
Jan 4 13:16:00 X1 kernel: [258126.858195] sd 1:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Jan 4 13:16:00 X1 kernel: [258126.867874] sdb: sdb1 sdb2 < sdb5 >
Jan 4 13:16:00 X1 kernel: [258126.869975] sd 1:0:0:0: [sdb] Attached SCSI removable disk
Jan 4 13:16:00 X1 kernel: [258127.138645] EXT4-fs (sdb1): INFO: recovery required on readonly filesystem
Jan 4 13:16:00 X1 kernel: [258127.138646] EXT4-fs (sdb1): write access unavailable, cannot proceed (try mounting with noload)
Jan 4 13:16:00 X1 gnome-shell[1852]: Unable to mount volume 767 MB Volume: Gio.IOErrorEnum: Error mounting /dev/sdb1 at /media/peter/0b776e27-d039-4fc5-ad20-462e5e36e031: cannot mount /dev/sdb1 read-only
Jan 4 13:16:03 X1 systemd-resolved[924]: Got packet on unexpected IP range, refusing.
Jan 4 13:16:03 X1 systemd-resolved[924]: Got packet on unexpected IP range, refusing.
Jan 4 13:16:05 X1 gnome-shell[1852]: Unable to mount volume 250 GB Encrypted: Gio.IOErrorEnum: Operation was cancelled
Jan 4 13:16:05 X1 udisksd[1095]: Unlocked LUKS device /dev/sdb5 as /dev/dm-3
如果我尝试挂载 /dev/dm-3,我只得到。
未知的文件系统类型‘LVM2_member’。
lvmdiskscan 向我显示了卷:
/dev/mapper/luks-477637dc-44d2-4076-9519-194cc4bf46c6 [ 232,53 GiB] LVM physical volume
但是lvs
或者lvscan
不要向我显示任何与 USB 驱动器相关的东西。
我猜想它失败了,并且进入了某种只读模式。我想知道是否有某种方法可以将根分区 /dev/sdb5 挂载为只读,以便仍然尝试从中获取一些内容?也许我可以去dd /dev/dm-3
其他地方尝试挂载它?
答案1
作为记录:
最后,我又尝试将数据保存在快坏掉的 USB 盘上的加密分区上,但 USB 盘显然已进入只读模式,因此无法挂载实际分区(至少在我看来是这样)。将 USB 盘插入 USB 端口仍会显示密码提示,分区将被解密,但无法挂载。因此,复制整个解密映像,然后将其作为环回设备挂载似乎是可行的方法:
sudo dd if=/dev/dm-3 of=tmp/oldstick status=progress
大约 250 GB 的文件需要花费大约 8 小时。接下来,必须将新复制的映像与环回设备连接起来。
sudo losetup --all
表明到现在为止的所有内容/dev/loop17
都已在使用中,因此必须采用第 18 项:
sudo losetup /dev/loop18 tmp/oldstick
之后它出现在 的输出中sudo pvs
,但与当前运行的系统具有相同的 VG。在 的不同调用中尝试了几次vgrename
,然后我发现了vgimportclone
。再次尝试失败了几次,成功的一次似乎是
sudo vgimportclone -i /dev/loop18
sudo pvs
,之后它出现在as的输出中ubuntu-vg1
。
sudo vgchange -a y ubuntu-vg1
然后会激活该卷,然后sudo lvscan
会输出以下行:
ACTIVE '/dev/ubuntu-vg1/root' [231,57 GiB] inherit
然后它指出了我需要使用哪个设备作为 mount 命令的参数,这样经过几次失败的尝试后
sudo mount -o ro /dev/ubuntu-vg1/root tmp/oldroot/
最终让我回到了旧系统。
这种方法的灵感主要来自于这里。