2

there is a volume in raid10 /dev/md3 it has a GPT partition /dev/md3p1 in ext4 with a size of 16TB.

I accidentally ran

fsck -y /dev/md3

causing the filesystem in /dev/md3p1 to get corrupted.

fsck -b superblock_number /dev/md3p1 with any superblock from mkfs -n /dev/md3p1 returns an error.

testdisk in /dev/md3 sees ext4 partition, but in /dev/md3p1 sees nothing.

How to recover data or partition?

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
user607743
  • 23
  • 3

1 Answers1

1

if you have tried with all superblocks, you may want to check out mke2fs' man mage, and maybe try it with the -S to re-init superblock and group descriptors (first, see the man page for warnings).

... you need to run fsck immediately afterwards, and have the right block size in hand.

JRM.
  • 26
  • 1
  • mkfs -S /dev/md3p1 ? and fsck -b block_number /dev/md3p1 – user607743 Dec 29 '20 at 10:32
  • correct, since mkfs calls mke2fs. Please check the man page before you attempt it: https://linux.die.net/man/8/mke2fs ...and again, I would try this only if you have already tried using all the superblock backups. – JRM. Dec 29 '20 at 17:01
  • ...also, know that after running fsck, there might be some stuff dumped into lost+found. ...so again, I would try this only if you have already tried using all the superblock backups. – JRM. Dec 29 '20 at 17:15
  • mkfs -S /dev/md3p1 ...or if you happen to know the block size of the partition: mkfs -S -b /dev/md3p1 ...maybe this can help getting the block size: dumpe2fs /dev/md3p1 | grep -i block | grep -i size or stat -f /dev/md3p1 dumpe2fs will also get you all the superblocks backups listed,.. then you can make sure mkfs -n list matches dumpe2fs. – JRM. Dec 29 '20 at 18:10