How to recover LVM structure after a disk crash

root's picture

If you get issues regarding failed disks on some linux machines and you may be forced to recreate the VG structure here are the necessary steps to do it:

ONLY IF /etc/lvm/backup/_VG_NAME_ exists
1. recover the UID of the failed disk
sed -n '/pv0 /{n;p;}' /etc/lvm/backup/vg_root |sed 's/.*"\(.*\)\"/\1/'
1.1 assign the value to $OLD_UID variable
2. prepare the new disk with the old UID
pvcreate -ff -v -u $OLD_UID /dev/sdb1
3. restore VG structure
vgcfgrestore -f /etc/lvm/backup/vg_root vg_root
3.1 reactivate VG
vgchange -ay vg_root
4. recreate the FS & mount them

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.

Recent content