Ext4

fsck raid10 ext4 分區損壞,恢復數據

  • December 28, 2020

raid10 中有一個卷,/dev/md3 它在 ext4 中有一個 GPT 分區/dev/md3p1,大小為 16TB。

我不小心跑了

fsck -y /dev/md3

導致文件系統/dev/md3p1損壞。

fsck -b superblock_number /dev/md3p1任何超級塊 frommkfs -n /dev/md3p1都會返回錯誤。

testdisk in/dev/md3看到 ext4 分區,但 in/dev/md3p1什麼也沒看到。

如何恢復數據或分區?

sudo parted -l /dev/md3

Model: ATA WDC WD8003FFBX-6 (scsi)
Disk /dev/sda: 8002G
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
1      1049kB  538MB   537MB   fat32              boot, esp
2      538MB   1612MB  1074MB
3      1612MB  55.3GB  53.7GB
4      55.3GB  66.0GB  10.7GB
5      66.0GB  8002GB  7936GB


Model: ATA WDC WD8003FFBX-6 (scsi)
Disk /dev/sdb: 8002GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
1      1049kB  538MB   537MB   fat32              boot, esp
2      538MB   1612MB  1074MB
3      1612MB  55.3GB  53.7GB
4      55.3GB  66.0GB  10.7GB
5      66.0GB  8002GB  7936GB


Model: ATA WDC WD8003FFBX-6 (scsi)
Disk /dev/sdc: 8002GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
1      1049kB  538MB   537MB   fat32              boot, esp
2      538MB   1612MB  1074MB
3      1612MB  55.3GB  53.7GB
4      55.3GB  66.0GB  10.7GB
5      66.0GB  8002GB  7936GB


Model: ATA WDC WD8003FFBX-6 (scsi)
Disk /dev/sdd: 8002GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
1      1049kB  538MB   537MB   fat32              boot, esp
2      538MB   1612MB  1074MB
3      1612MB  55.3GB  53.7GB
4      55.3GB  66.0GB  10.7GB
5      66.0GB  8002GB  7936GB

sudo mount /dev/md3p1 /1

mount: /1: wrong fs type, bad option, bad superblock on /dev/md3p1, missing codepage or helper program, or other error.

sudo mkfs -n /dev/md3p1



mke2fs 1.44.1 (24-Mar-2018)
Creating filesystem with 3874701824 4k blocks and 484339712 inodes
Filesystem UUID: dc34be44-6f5a-47ac-a841-cbb75625b9b0
Superblock backups stored on blocks: 
   32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
   4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
   102400000, 214990848, 512000000, 550731776, 644972544, 1934917632, 
   2560000000, 3855122432

sudo fsck -b 32768 /dev/md3p1

fsck from util-linux 2.31.1
e2fsck 1.44.1 (24-Mar-2018)
fsck.ext2: Bad magic number in super-block while trying to open /dev/md3p1

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>

cat /proc/mdstat


Personalities : [raid1] [raid10] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] 
md0 : active raid1 sdc2[6] sdb2[5] sda2[4] sdd2[0]
     1046528 blocks super 1.2 [4/4] [UUUU]
     
md1 : active raid1 sdb3[6] sdc3[5] sdd3[0] sda3[4]
     52395008 blocks super 1.2 [4/4] [UUUU]
     
md2 : active raid10 sdb4[5] sda4[4] sdc4[3] sdd4[0]
     20953088 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]
     
md3 : active raid10 sda5[1] sdd5[0] sdc5[3] sdb5[2]
     15498811392 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]
     bitmap: 0/116 pages [0KB], 65536KB chunk

如果您已經嘗試過所有超級塊,您可能需要查看 mke2fs 的 man mage,並可能嘗試使用 -S 重新初始化超級塊和組描述符(首先,請參閱手冊頁以獲取警告)。

…您需要在之後立即執行 fsck,並掌握正確的塊大小。

引用自:https://serverfault.com/questions/1047333