大网数据广告活动
服务器运维问答

Recover the file system from a corrupted RAID1

· 52CE 我爱测

TL;DR How to recover the ext4 file system from a corrupted RAID1 partition? My situation I have one failed disk that belonged to an RAID1 array on a Synology DiskStation, the other one is lost. Using ddrescue I've copied most of …

问题原文

原帖链接 · Jakub · CC BY-SA 3.0

TL;DR How to recover the ext4 file system from a corrupted RAID1 partition?

My situation

I have one failed disk that belonged to an RAID1 array on a Synology DiskStation, the other one is lost. Using ddrescue I've copied most of the relevant data to a new disk. The partition table survied, however some blocks essential to the RAID setup are corrupted.

# fdisk -l /dev/sdd
Disk /dev/sdd: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0003f44a

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1             256     4980735     2490240   fd  Linux raid autodetect
/dev/sdd2         4980736     9175039     2097152   fd  Linux raid autodetect
/dev/sdd3         9437184  3907024064  1948793440+  fd  Linux raid autodetect

The actual data is on the third partition /dev/sdd3, but mdadm can't assemble the array.

# mdadm --examine /dev/sdd
/dev/sdd:
   MBR Magic : aa55
Partition[0] :      4980480 sectors at          256 (type fd)
Partition[1] :      4194304 sectors at      4980736 (type fd)
Partition[2] :   3897586881 sectors at      9437184 (type fd)


# mdadm --examine /dev/sdd3
mdadm: No md superblock detected on /dev/sdd3.

As a result I am unable to mount the partition. The data is there and it is recognized by tools like foremost.

I have also tried using extundelete, but it fails without a proper ext superblock.

# extundelete --superblock /dev/sdd3
extundelete: failed to read-only open device "/dev/sdd3": Error code 2133571347

The question(s)

How to recover files and directories from a corrupted RAID1 partition?

Is there any way to recreate the md superblock, without loosing the existing data?

Would it be possible to ignore the md parts, to treat the partition as a corrupted ext4 partition and recover it that way?

已采纳解答

原帖链接 · Tero Kilkanen · CC BY-SA 3.0

You can use a loop mount to mount a partition in your disk image as a device. When creating the loop device, you give an offset which makes the loop device begin at that spot in the partition.

This way you can skip the missing MD superblock, and make the loop device start at the start of the ext4 partition or possible LVM.

Now, we need to know the size of the MD superblock in order to provide proper offset when creating loop device.

From MD manual article, one can see the superblock sizes and locations for different MD versions.

0.9 and 1.0 versions have the superblock at the end of the device, therefore the filesystem starts at the start of the device, and your mount command should have succeeded. So, your RAID Superblock must be some other version.

1.1 version has the superblock at start of the device, and 1.2 version has the superblock at 4k from start of the device.

However, there is plenty of space reserved for possible superblock expansion later on. One source tells me that the filesystem would start one megabyte after device start. In this case, you would try the following commands:

losetup /dev/loop0 /dev/sdd3 -o 1048576
mount /dev/loop0 /mnt

The first command sets up a loop device that starts at offset at one megabyte from the /dev/sdd3 partition start. Then, this loop device is mounted under /mnt.

The offset can be something else though, and unfortunately I couldn't find a good source for what the offsets could actually be.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-10-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。