我有一台 windows10 - ubuntu 18.04 双启动计算机。上面有三个驱动器:
- 512 GB SSD,带 Ubuntu 系统
- 1 TB HD,带 Windows 系统
- 1 TB HD Ext4 格式(有问题的)用于额外的数据存储
在使用 Windows 10 时,我想访问 Ext4 HD,但忘记了它是 Ext4。进入计算机管理 -> 存储并将磁盘从离线切换为在线。Windows 询问是否应创建 GPT 或 MBR 分区表。类似于(目前没有截图 :) )
选择 GPT,然后 Windows 创建 17MB 分区并将剩余空间标记为原始数据(在 ubuntu 中截取的屏幕截图)。
这时我意识到我没有做我想做的事情,所以没有做任何其他事情就回到了 ubuntu。
通过在线阅读找到了 Testdisk,并将其用于有问题的 HD。1.- 创建日志文件(完整日志文件内容添加到帖子末尾)
TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <[email protected]>
http://www.cgsecurity.org
TestDisk is free data recovery software designed to help recover lost
partitions and/or make non-booting disks bootable again when these symptoms
are caused by faulty software, certain types of viruses or human error.
It can also be used to repair some filesystem errors.
Information gathered during TestDisk use can be recorded for later
review. If you choose to create the text file, testdisk.log , it
will contain TestDisk options, technical information and various
outputs; including any folder/file names TestDisk was used to find and
list onscreen.
Use arrow keys to select, then press Enter key:
>[ Create ] Create a new log file
[ Append ] Append information to log file
[ No Log ] Don't record anything
2.- 选定有问题的磁盘
Select a media (use Arrow keys, then press Enter):
>Disk /dev/sda - 1000 GB / 931 GiB - WDC WD10EZEX-08WN4A0
Disk /dev/sdb - 1000 GB / 931 GiB - WDC WD10EZEX-22MFCA0
Disk /dev/sdc - 4000 GB / 3725 GiB - WD Elements 25A1
>[Proceed ] [ Quit ]
根据 Testdisk 建议选择分区类型
Disk /dev/sda - 1000 GB / 931 GiB - WDC WD10EZEX-08WN4A0
Please select the partition table type, press Enter when done.
[Intel ] Intel/PC partition
[EFI GPT] EFI GPT partition map (Mac i386, some x86_64...)
[Humax ] Humax partition table
[Mac ] Apple partition map
>[None ] Non partitioned media
[Sun ] Sun Solaris partition
[XBox ] XBox partition
[Return ] Return to disk selection
Hint: None partition table type has been detected.
Note: Do NOT select 'None' for media with only a single partition. It's very
rare for a disk to be 'Non-partitioned'.
3.- 选择分析类型
Disk /dev/sda - 1000 GB / 931 GiB - WDC WD10EZEX-08WN4A0
CHS 121601 255 63 - sector size=512
[ Analyse ] Analyse current partition structure and search for lost partitions
>[ Advanced ] Filesystem Utils
[ Geometry ] Change disk geometry
[ Options ] Modify options
[ Quit ] Return to disk selection
4.- 根据建议执行超级块
Disk /dev/sda - 1000 GB / 931 GiB - CHS 121601 255 63
Partition Start End Size in sectors
> P ext4 0 0 1 121601 80 63 1953525168 [data]
[ Type ] >[Superblock] [ List ] [Image Creation] [ Quit ]
超级区块结果
Disk /dev/sda - 1000 GB / 931 GiB - CHS 121601 255 63
Partition Start End Size in sectors
ext4 0 0 1 121601 80 63 1953525168 [data]
superblock 32768, blocksize=4096 [data]
superblock 98304, blocksize=4096 [data]
superblock 163840, blocksize=4096 [data]
superblock 229376, blocksize=4096 [data]
superblock 294912, blocksize=4096 [data]
superblock 819200, blocksize=4096 [data]
superblock 884736, blocksize=4096 [data]
superblock 1605632, blocksize=4096 [data]
superblock 2654208, blocksize=4096 [data]
superblock 4096000, blocksize=4096 [data]
To repair the filesystem using alternate superblock, run
fsck.ext4 -p -b superblock -B blocksize device
>[ Quit ]
如上所示,Testdisk 发挥了“魔法”,并建议使用fsck.ext4 -p
特定的块号和块大小
sudo fsck.ext4 -p -b 32768 -B 4096 /dev/sda
[sudo] password for alfonso:
data was not cleanly unmounted, check forced.
data: Group 1 inode bitmap does not match checksum.
FIXED.
data: Group 0 block bitmap does not match checksum.
FIXED.
data: 65949/61054976 files (0.7% non-contiguous), 189540323/244190646 blocks
完成此操作后,我就可以访问有问题的 HD,并且在安装时所有数据似乎都完好无损。
lsblk
运行后输出fsck.ext4
,如评论中所建议
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 175,4M 1 loop /snap/postman/133
...
loop28 7:28 0 61,9M 1 loop /snap/core20/1169
sda 8:0 0 931,5G 0 disk /media/alfonso/data
sdb 8:16 0 931,5G 0 disk
├─sdb1 8:17 0 529M 0 part
├─sdb2 8:18 0 99M 0 part
├─sdb3 8:19 0 16M 0 part
└─sdb4 8:20 0 930,9G 0 part
sr0 11:0 1 1024M 0 rom
nvme0n1 259:0 0 477G 0 disk
├─nvme0n1p1 259:1 0 619M 0 part /boot/efi
├─nvme0n1p2 259:2 0 214,4G 0 part /
├─nvme0n1p3 259:3 0 34,5G 0 part [SWAP]
└─nvme0n1p4 259:4 0 227,5G 0 part /home
然而,重新启动后,我发现 HD 上有一个 GPT 表,但没有数据 :( 我重复了fsck.ext4
上述命令,数据又恢复了。
我的问题是,我怎样才能使fsck.ext4
更改永久生效?所以我不需要在每次启动 ubuntu 时运行它。
感谢您的帮助
Testdisk LOG 文件内容
Fri Oct 22 17:35:35 2021
Command line: TestDisk
TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <[email protected]>
http://www.cgsecurity.org
OS: Linux, kernel 4.15.0-161-generic (#169-Ubuntu SMP Fri Oct 15 13:41:54 UTC 2021) x86_64
Compiler: GCC 7.2
ext2fs lib: 1.44.1, ntfs lib: libntfs-3g, reiserfs lib: none, ewf lib: none, curses lib: ncurses 6.0
/dev/sda: LBA, HPA, LBA48, DCO support
/dev/sda: size 1953525168 sectors
/dev/sda: user_max 1953525168 sectors
/dev/sda: native_max 1953525168 sectors
/dev/sdb: LBA, HPA, LBA48, DCO support
/dev/sdb: size 1953525168 sectors
/dev/sdb: user_max 1953525168 sectors
/dev/sdb: native_max 1953525168 sectors
Warning: can't get size for Disk /dev/mapper/control - 0 B - 0 sectors, sector size=512
Hard disk list
Disk /dev/sda - 1000 GB / 931 GiB - CHS 121601 255 63, sector size=512 - WDC WD10EZEX-08WN4A0, S/N:WD-WCC6Y0VJ3LD1, FW:02.01A02
Disk /dev/sdb - 1000 GB / 931 GiB - CHS 121601 255 63, sector size=512 - WDC WD10EZEX-22MFCA0, S/N:WD-WCC6Y6FAJ869, FW:01.01A01
Disk /dev/sdc - 4000 GB / 3725 GiB - CHS 486397 255 63, sector size=512 - WD Elements 25A1, FW:1014
Partition table type (auto): None
Disk /dev/sda - 1000 GB / 931 GiB - WDC WD10EZEX-08WN4A0
Partition table type: None
Interface Advanced
recover_EXT2: "e2fsck -b 98304 -B 4096 device" may be needed
P ext4 0 0 1 121601 80 63 1953525168 [data]
ext4 blocksize=4096 Large_file Sparse_SB Backup_SB, 1000 GB / 931 GiB
search_superblock
block_group_nr 1
recover_EXT2: "e2fsck -b 32768 -B 4096 device" may be needed
recover_EXT2: s_block_group_nr=1/7452, s_mnt_count=0/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 244190646
recover_EXT2: part_size 1953525168
Ext2 superblock found at sector 262144 (block=32768, blocksize=4096)
block_group_nr 3
recover_EXT2: "e2fsck -b 98304 -B 4096 device" may be needed
recover_EXT2: s_block_group_nr=3/7452, s_mnt_count=0/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 244190646
recover_EXT2: part_size 1953525168
Ext2 superblock found at sector 786432 (block=98304, blocksize=4096)
block_group_nr 5
recover_EXT2: "e2fsck -b 163840 -B 4096 device" may be needed
recover_EXT2: s_block_group_nr=5/7452, s_mnt_count=0/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 244190646
recover_EXT2: part_size 1953525168
Ext2 superblock found at sector 1310720 (block=163840, blocksize=4096)
block_group_nr 7
recover_EXT2: "e2fsck -b 229376 -B 4096 device" may be needed
recover_EXT2: s_block_group_nr=7/7452, s_mnt_count=0/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 244190646
recover_EXT2: part_size 1953525168
Ext2 superblock found at sector 1835008 (block=229376, blocksize=4096)
block_group_nr 9
recover_EXT2: "e2fsck -b 294912 -B 4096 device" may be needed
recover_EXT2: s_block_group_nr=9/7452, s_mnt_count=0/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 244190646
recover_EXT2: part_size 1953525168
Ext2 superblock found at sector 2359296 (block=294912, blocksize=4096)
block_group_nr 25
recover_EXT2: "e2fsck -b 819200 -B 4096 device" may be needed
recover_EXT2: s_block_group_nr=25/7452, s_mnt_count=0/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 244190646
recover_EXT2: part_size 1953525168
Ext2 superblock found at sector 6553600 (block=819200, blocksize=4096)
block_group_nr 27
recover_EXT2: "e2fsck -b 884736 -B 4096 device" may be needed
recover_EXT2: s_block_group_nr=27/7452, s_mnt_count=0/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 244190646
recover_EXT2: part_size 1953525168
Ext2 superblock found at sector 7077888 (block=884736, blocksize=4096)
block_group_nr 49
recover_EXT2: "e2fsck -b 1605632 -B 4096 device" may be needed
recover_EXT2: s_block_group_nr=49/7452, s_mnt_count=0/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 244190646
recover_EXT2: part_size 1953525168
Ext2 superblock found at sector 12845056 (block=1605632, blocksize=4096)
block_group_nr 81
recover_EXT2: "e2fsck -b 2654208 -B 4096 device" may be needed
recover_EXT2: s_block_group_nr=81/7452, s_mnt_count=0/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 244190646
recover_EXT2: part_size 1953525168
Ext2 superblock found at sector 21233664 (block=2654208, blocksize=4096)
block_group_nr 125
recover_EXT2: "e2fsck -b 4096000 -B 4096 device" may be needed
recover_EXT2: s_block_group_nr=125/7452, s_mnt_count=0/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 244190646
recover_EXT2: part_size 1953525168
Ext2 superblock found at sector 32768000 (block=4096000, blocksize=4096)
ext4 0 0 1 121601 80 63 1953525168 [data]
superblock 32768, blocksize=4096 [data]
superblock 98304, blocksize=4096 [data]
superblock 163840, blocksize=4096 [data]
superblock 229376, blocksize=4096 [data]
superblock 294912, blocksize=4096 [data]
superblock 819200, blocksize=4096 [data]
superblock 884736, blocksize=4096 [data]
superblock 1605632, blocksize=4096 [data]
superblock 2654208, blocksize=4096 [data]
superblock 4096000, blocksize=4096 [data]
To repair the filesystem using alternate superblock, run
fsck.ext4 -p -b superblock -B blocksize device
TestDisk exited normally.
答案1
非常感谢兄弟的指导
我丢失了 4TB 硬盘中的所有数据,之前在 ubuntu 中将其用作未分区的 ext4 磁盘,像你一样,我安装了 Windows,当启动它并启动磁盘管理时,我只需按“初始化为 gpt”,然后返回 ubuntu 后,当我看到未分配的空间时,我感到很震惊,但不是所有的数据,天哪,天哪
感谢您和谷歌,我找到了这个帖子并像您一样完成了所有操作并恢复了我所有的数据,但这几个小时非常紧张哈哈再次感谢您并始终备份所有重要数据