Unable to mount raid on the NAS, trying to rescue the data, how should I proceed

mdadmmountraid

A short backstory: something happened on my Synology NAS, apparently a buggy mailserver program that came with an update stopped the device from seeing the 2x3TB drives I have. After a lot of searching and a trying a lot of different solutions I eventually got the drives to show up again but they would not mount. After struggling, I figured that, because it was set up as a mirror, I could format one drive, mount it and perform the recovery on the other.

EDIT: I had it wrong and was trying to mount the wrong disk (not used to messing around with raid), however, I'm still unable to mount the correct disk, sda

$ file -s /dev/sda1
/dev/sda1: data
$ mount -t ext4 /dev/sda1 /mnt               
mount: mounting /dev/sda1 on /mnt failed: Invalid argument

Further Info

$ cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / ext4 rw,relatime,barrier=0,journal_checksum,data=ordered 0 0
/proc /proc proc rw,relatime 0 0
/tmp /tmp tmpfs rw,relatime 0 0
none /dev/pts devpts rw,relatime,gid=4,mode=620 0 0
/sys /sys sysfs rw,relatime 0 0
/proc/bus/usb /proc/bus/usb usbfs rw,relatime 0 0
/dev/vg1000/lv /volume1 ext4 rw,relatime,synoacl,barrier=0,journal_checksum,data=writeback,jqfmt=vfsv0,usrjquota=aquota.user,grpjquota=aquota.group 0 0
/dev/vg1000/lv /opt ext4 rw,relatime,synoacl,barrier=0,journal_checksum,data=writeback,jqfmt=vfsv0,usrjquota=aquota.user,grpjquota=aquota.group 0 0

Best Answer

This is an attempt to summarize from the chat troubleshooting session.

The setup turns out to be physical disk -> mdraid raid1 -> LVM. So there are several layers to work through. The old setup was (due to unfortunate prior recovery efforts) not available.

However, the NAS gui had been used to create another volume on a different disk, and thankfully the GUI created the new volume exactly the same way. So it was possible to discover the setup from the new disk:

  • mdadm -E new-disk provided the offset to the start of the data, under the mdraid layer (2048 sectors).
  • dmsetup table provided the start block of the logical volume (relative to the start of the physical volume) (1152 sectors)
  • There is a magic number (0x53ef) in the third sector of an ext4 volume. Using dd and xxd, we verified that the magic number is present at that offset on the disk we're trying to recover data from.

Armed with the start sector of the ext4 filesystem, you can use a read-only loop device to recover the data:

# losetup /dev/loop0 -o $((512*(1152+2048))) -r /dev/sda1
# mount -text4 -o ro /dev/loop0 /mnt

And then copy it off.

Related Question