Examining a RAID member from a disk image with dd_rescue and mdadm

guide · linux

When a drive is failing, the safe order is: image it first, then work only on the image.

possibly outdated More than two years have passed since publication. The content may no longer hold.
01

1. Image the drive

dd_rescue /dev/damaged_hdd /mountpoint/file
02

2. Find the partitions

Attach the image to a loop device and print its partition table:

losetup /dev/loop0 /mountpoint/file
fdisk -l -u /dev/loop0

Note the start and end sectors of the partition you need (for example a Linux raid autodetect partition).

Then map just that partition to its own loop device:

losetup -o $((start*512)) --sizelimit $(((end-start+1)*512)) /dev/loop1 /mountpoint/file
03

3. Inspect the RAID member

mdadm --examine /dev/loop1
04

Additional commands

  • Detach a loop device:
losetup -d /dev/loop1
  • Assemble the array:
mdadm --assemble --force /dev/md0 /dev/device...

_Originally published in March 2013._

← back to explore