Linux RAID – recreate from scratch

Posted January 5, 2006 by MrIce in Linux

How to recreate the raid devices on a Linux system if you are booting from rescue media or alternate system (such as a CDROM based distro like Knoppix).

I recently had to boot a system from alternate media to repair some configuration problems on the system. The disks are LVM on top of software RAID 1. The rescue media didn’t detect or recreate the RAID devices so the LVM volumes (and thus the system data) were not available.

To recreate the RAID partition, use the mdadm command like this (only do this if /etc/mdadm/mdadm.conf is empty or isn’t working).

echo DEVICE partitions > /etc/mdadm/mdadm.conf
/sbin/mdadm --examine --scan >> /etc/mdadm/mdadm.conf
/sbin/mdadm --assemble --scan

Then, LVM will work with just a couple more commands. Note that vgscan writes the lvmtab files to /etc and about 500KB per volume group will be required. This was an issue on my Knoppix 3.2 rescue platform.

vgchange -ay

To list the logical volumes use sudo /usr/sbin/lvm lvscan

Then you can mount and fix whatever you need to.

The Conversation

Follow the reactions below and share your own thoughts.