Linux RAID – recreate from scratch

Contributor Icon Contributed by MrIce  
Tag Icon Tagged: 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.

vgscan
vgchange -ay

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

Then you can mount and fix whatever you need to.

 

2 Comments -


  1. Mark Trent said on May 21, 2009

    Thank you so much!

    You Just saved my bacon with this guide!

    If you are ever in my neck of the woods please swing buy I owe you at the very least a bottle of whisky!

    Thanks a ton!

  2. Ddd said on May 4, 2011

    Thanks a million. I just had to recreate my server and I couldn’t find out how to do exactly what you are describing here.

 

RSS feed for comments on this post. TrackBack URL

Leave a comment -