Mounting a Linux software raid array with lvm
I recently had a hard drive crash on my home Linux NAS box. The important files were on a software raid 5 array, but the root filesystem (with the majority of the OS) were on a separate IDE hard drive.Only the IDE drive crashed so my important files were safe, but I needed to remount the raid array. It took me quite a while before I got that right, so I'll share my knowledge here for you. Here are the commands needed to reconstruct / remount a raid array with a Gentoo live cd:load the raid module and lvm driver if you need to:# modprobe raid5# modprobe dm-mod
Find the UUID's of the devices
( you can skip this step if you have a backup of your /etc/mdadm.conf file )# mdadm --examine --scan /dev/sda1
Where /dev/sda1 points to one of the partitions used for the raid array. The output looks like this on my box:ARRAY /dev/md1 level=raid5 num-devices=4 UUID=94366f38:ccdadda0:06f85cb1:f1263d52
copy it to /etc/mdadm.conf# mdadm --examine --scan /dev/sda1 >> /etc/mdadm.conf
Now we need to add a list of devices to mdadm.conf of where to look for member disks:(manually add this to mdadm.conf, the devices i had to add where /dev/sda1 to /dev/sdd1)
DEVICE /dev/sd[abcd]1
At the end that leaves us with this in our mdadm.conf file:DEVICE /dev/sd[abcd]1ARRAY /dev/md1 level=raid5 num-devices=4 UUID=94366f38:ccdadda0:06f85cb1:f1263d52
Assemble the raid array
We make the mirror device node:# mknod /dev/md1 b 9 1
Assemble the array:# mdadm --assemble --scan
You can check /proc/mdstat to see if the array is online:# cat /proc/mdstatPersonalities : [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]md1 : active raid5 sda1[0] sdd1[3] sdc1[2] sdb1[1] 937705728 blocks level 5, 64k chunk, algorithm 2 [4/4] [UUUU]
Activate the logical volumes
# vgscan
Scans your disk and should show you the Volume Group that was on the raid array and add it to the lvm database# vgchange -ay
This should activate the volumes and auto create the nodes in /devMount the filesystems
I just needed to mount the filesystems just like I would mount a regular one:mount --type ext3 /dev/vg2/var /mnt/gentoo/var
Hope this helps someone!