从卸载的 nvme 恢复数据

从卸载的 nvme 恢复数据

给出一个背景信息:从大约 10 个月前开始,我习惯通过进入 grub 来启动我的 Ubuntu,然后输入如下内容:

set root=(hd0,gpt3)
linux /boot/vmlinuz-5.19.1-051901-generic root=/dev/nvme0n1p3
initrd /boot/initrd.img-5.19.1-051901-generic
boot

如果没有这个系统,启动时角落就会闪烁并冻结_。真正的问题发生在我可能更改 sudo.cnf 文件的所有者(不记得文件名)时。我必须在容器中执行该命令,但可能没有。效果很明显,我无法使用任何 sudo 命令。当我的 dell g3 意外重启时,我的 grub 解决方案停止工作。我制作了实时 usb 并尝试在当前 ubuntu 旁边安装全新的 ubuntu 以访问旧文件,但该过程Removing conflicting operating system files永远持续下去(21 小时以上)。在这 21 小时后的日志中,我只能看到一些粗略操作和很多XDG_RUNTIME_DIR (/run/user/999) is not owned by us (uid 0), but by uid 999! (This could e.g. happen if you try to connect to a non-root PulseAudio as a root user, over the native protocol. Don't do that.)。我放弃了这个想法,尝试通过Try Linux选项获取旧文件。所以我的lsblk输出是

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0         7:0    0     3G  1 loop /rofs
loop1         7:1    0     4K  1 loop /snap/bare/5
loop2         7:2    0  63.4M  1 loop /snap/core20/1974
loop3         7:3    0 237.2M  1 loop /snap/firefox/2987
loop4         7:4    0  73.9M  1 loop /snap/core22/858
loop5         7:5    0 349.7M  1 loop /snap/gnome-3-38-2004/143
loop6         7:6    0 485.5M  1 loop /snap/gnome-42-2204/120
loop7         7:7    0  91.7M  1 loop /snap/gtk-common-themes/1535
loop8         7:8    0  12.3M  1 loop /snap/snap-store/959
loop9         7:9    0  53.3M  1 loop /snap/snapd/19457
loop10        7:10   0   452K  1 loop /snap/snapd-desktop-integration/83
sda           8:0    1  57.3G  0 disk 
├─sda1        8:1    1   4.7G  0 part /cdrom
├─sda2        8:2    1   4.9M  0 part 
├─sda3        8:3    1   300K  0 part 
└─sda4        8:4    1  52.6G  0 part /var/crash
                                      /var/log
nvme0n1     259:0    0     0B  0 disk 
├─nvme0n1p1 259:1    0   750M  0 part 
├─nvme0n1p2 259:2    0     5G  0 part 
└─nvme0n1p3 259:3    0 471.2G  0 part 

所以我尝试挂载nvme0n1-mount /dev/nvme0n1p3 /mnt输出是mount: /mnt: can't read superblock on /dev/nvme0n1p3.我尝试使用它sudo blkid /dev/nvme0n1p3来识别文件系统类型,但没有输出。下一个sudo e2fsck -f /dev/nvme0n1p3输出是

e2fsck 1.46.5 (30-Dec-2021)
e2fsck: Input/output error while trying to open /dev/nvme0n1p3

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>

当然,给定的替代超级块也不起作用。我在安装任何smartmontoolstesdisk由于时遇到问题E: You don't have enough free space in /var/cache/apt/archives/。我尝试sudo badblocks -v /dev/nvme0n1p3并得到Pass completed, 494095360 bad blocks found. (494095360/0/0 errors)。然后我尝试制作磁盘映像,通过sudo dd if=/dev/nvme0n1p3 of=my_data bs=4096 conv=noerror,sync该映像成功处理了 3.5 Gb 文件。在另一台电脑上运行 testdisk 后,我得到了Partition sector doesn't have the endmark 0xAA55,然后我意识到我应该这样做sudo dd if=/dev/nvme0n1 of=my_data bs=4096 conv=noerror,sync(整个磁盘而不仅仅是 p3),但为此我得到了输出

0+0 records in
0+0 records out
0 bytes copied, 0.00926212 s, 0.0 kB/s

我还认为也许我从测试磁盘中选择了错误的选项(Intel(我选择这个),EFI GPT),所以我尝试使用

hexdump -C -n 100000 my_data

但我只得到零(这可能是我仅从 nvme0n1p3 制作磁盘映像的结果)。最后我还可以分享sudo dmesg | grep nvme0n1整个结果

[ 2694.176430] Buffer I/O error on dev nvme0n1p3, logical block 3121868, async page read
[ 2694.176434] Buffer I/O error on dev nvme0n1p3, logical block 3121868, async page read
[ 2694.176439] Buffer I/O error on dev nvme0n1p3, logical block 3121869, async page read
...
[ 4080.276514] Buffer I/O error on dev nvme0n1p3, logical block 123095574, async page read

您认为有机会访问旧文件吗?也许从旧实例中通过 grub 访问这些文件比尝试从 live-usb 挂载它更容易?也许可以解决 sudo.conf 所有者的问题,这样就不需要重新安装了?有输出lsblk -e 7 -f

NAME FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda  iso966 Jolie Ubuntu 22.04.3 LTS amd64
│                       2023-08-08-01-19-05-00                              
├─sda1
│    iso966 Jolie Ubuntu 22.04.3 LTS amd64
│                       2023-08-08-01-19-05-00                     0   100% /cdrom
├─sda2
│    vfat   FAT12 ESP   F7DB-4D56                                           
├─sda3
└─sda4
     ext4   1.0   writable
                        1c62f603-24f6-43ad-87c7-e7dcb7952498   48.8G     0% /var/crash
                                                                            /var/log
nvme0n1
├─nvme0n1p1
├─nvme0n1p2
└─nvme0n1p3

为了智能工具我有这个输出

sudo smartctl -i /dev/nvme0n1
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-6.2.0-26-generic] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

Read NVMe Identify Controller failed: NVME_IOCTL_ADMIN_CMD: Input/output error

无法点击,SMART data and self-tests因为它是灰色的从磁盘应用程序截屏

sudo gdisk -l /dev/nvme0n1
GPT fdisk (gdisk) version 1.0.8

Problem reading disk in BasicMBRData::ReadMBRData()!
Warning! Read error 22; strange behavior now likely!
Warning! Read error 22; strange behavior now likely!
Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. 
***************************************************************

Disk /dev/nvme0n1: 0 sectors, 0 bytes
Model: IM2P33F3A NVMe ADATA 512GB              
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 92747669-254D-443B-AD8F-8D69F42029D7
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 18446744073709551582
Partitions will be aligned on 2048-sector boundaries
Total free space is 0 sectors (0 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name

相关内容