You are here

Recovery From Half An MD Mirrored Pair

In the process of decommissioning an old physical server I wanted to recover some data from the server's drives. The failing server was configured with a SATA RAID1 pair that contained a logical volume group (LVM). So I could either boot up the old server, change it's IP address, and recover the data over the network.... or I could just recover the data directly from one of the drives [they are a mirrored pair after all]. But only having a USB caddy for one SATA drive the trick was to get the RAID1 array to come up on my laptop with only one drive.

Step#1) Connect the drive.

beast:~ # fdisk -l
Disk /dev/sdd: 80.0 GB, 80026361856 bytes
Disk identifier: 0x0007236b
   Device Boot    Start       End   Blocks Id  System
/dev/sdd1   *        63    530144   265041 fd  Linux raid autodetect
/dev/sdd2        530145   8916074  4192965 fd  Linux raid autodetect
/dev/sdd3       8916075 156296384 73690155 fd  Linux raid autodetect
Text 1: Connect the drive and look at the partition table of the new SD device.

Yep. There are three RAID partitions. I know the first tiny one was for "/boot" and the second larger one was for swap - the one I wanted was the third, and largest, partition which was the physical volume group that contained the data I wanted to recover.

Step#2) Create a "new" RAID device.

Create a new level 0 [no redundancy] RAID device with mdadm from a redundant portion of the previous RAID device.

beast:~ # mdadm --build --force --level=0 --raid-devices=1 /dev/md3 /dev/sdd3
mdadm: array /dev/md3 built and started.

The only gotcha here is to use an MD device that is not already in use. Since I already have an md0, md1, and md2 on my laptop I create this new device as md3.

Step#3) Activate the volume group.

Scan for and activate the old volume group.

beast:/home/awilliam # vgchange -ay
  4 logical volume(s) in volume group "Beast" now active
  3 logical volume(s) in volume group "KPAYL17" now active

vgchange -ay finds the volume group on my laptop "Beast" but also discovers and activates the volume group that existed on the LVM physical volume in the new/old RAID volume.

Aside: Note that prior to this point I never wrote anything to the recovered volume, I'm just building up around and on top of it. This is also a good point to point out why every server, SAN, or JBOD should use an LVM volume group with a unique name. If every volume group is named "System" then recovery just becomes that much more tedious - trying to activate a "System" volume group on a host that already has a "System" volume group...

Step#4) Mount the recovered logical volume.

Now I can mount the SRV logical volume from the recovered volume group from the physical volume on the new/old RAID device from the physical drive from the old server.

beast:/home/awilliam # mount /dev/KPAYL17/SRV /mnt

Data recovered! Have coffee.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer