Recover Softraid/LVM

Mon 06 February 2012
By makefu

MD Array fails to assemble

Find the Problem

#?/bin/sh
cat /proc/mdstat
mdadm -D --scan
mdadm -E --scan
mdadm -E /dev/sd[abcdef]1

Trying to assemble manually

#?/bin/sh
mdadm --stop /dev/md{0,127}
mdadm --assemble /dev/md0 /dev/sd{a,b,c,d,e,f}1 --force

recover a failed device in the array

#?/bin/sh
mdadm /dev/md0 --re-add /dev/sdx1 # will likely fail
mdadm --zero-superblock /dev/sdx1 # reap the device
echo 200000 > /proc/sys/dev/raid/speed_limit_min # speed up recovery
mdadm /dev/md0 --add /dev/sde1
sleep 56000 && echo "FINISHED!"

Recover LVM after doing something stupid

Restore VolGroup Partitioning

#?/bin/sh
# imagine you did something like 'vgremove vg'
vgdisplay -v # > logical volume: empty :(
# lvm stores backup of partitioning, yay
vgcfgrestore -f /etc/lvm/archive/vg_00018-2146062166.vg -v vg
vgchange -ay
vgdisplay -v # > logical volume: files1
e2fsck /dev/vg/files1
mount /dev/vg/files1

Comments