Jon’s Diary

Recovering lost MDADM Raid partitions and LVM volume groups and logical volumes in Linux

by Jon on Apr.15, 2009, under Computers, Linux

For some reason, I was once silly enough to create an mdadm RAID array using physical disks rather than creating a primary partition on each disk and creating the array from those. Because of this, when one of my servers boots, LVM cannot find it’s partitions since the array hasn’t been assembled at that point in the boot process. Or something. I’m not entirely sure, since it was never important enough to spend too much time worrying about.

Anyway, when the machine eventually boots (I’ve removed the mounts from /etc/fstab for the logical volumes on this misbehaving array) I’m left with the issue of finding the missing logical volumes and mounting them.

If I run vgscan now, I only see the volumes on the other disks, not those on the missing RAID array.

First issue is that the md device doesn’t exist (/dev/md2 is missing). Find the names of the devices you added to the array:
fdisk -l

Check that the devices are really members of the array:
mdadm --examine /dev/hdb /dev/hdd

Query the physical devices (this creates the missing md device):
mdadm -Q /dev/hdb /dev/hdd

Check that the md device was created correctly (should currently be inactive):
mdadm -Q /dev/md2

Assemble and activate the array:
mdadm --assemble /dev/md2

You should now be able to query the RAID device:
mdadm -Q /dev/md2
or
mdadm --detail /dev/md2

Next we search for the volume groups stored on the array:
vgscan
It should now show the names of the missing volumes which weren’t shown earlier.

Scan for the missing logical volumes:
lvscan
It should list a load of existing (assuming you have other volumes) logical volumes, and the missing ones listed as inactive.

To activate them and create the missing logical devices we run another
lvchange -ay <volume_name>
eg, if lvscan listed volumes x,y,z in the volume group /dev/datavg then activate them and create the logical devices with:
lvchange -ay datavg

Now you can mount the volume you need:
mount /dev/<volume_group>/<logical_volume> <mount_point>


Leave a Reply

You must be logged in to post a comment.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...