[en] How to mount LVM VG and restore data from it when one of its PV drives has failed

Howe­ver gre­at LVM is in Linux, allo­wing one to span sin­gle „par­ti­tion” over seve­ral hard dri­ves, if the under­ly­ing „dri­ves” are real hard dri­ves and not RAID volu­mes, You can get pret­ty fuc­ked when one of tho­se disks fails.

It took me seve­ral hours of googling aro­und and trials to find out how to reco­ver as much data as is possi­ble (meaning: all the data that is on rema­ining disks, the data on failed dri­ve is obvio­usly lost). So let’s try to add a short and wor­king reci­pe to Google.

  1. You do NOT have to pvcre­ate any bogus emp­ty PVs with fake UUIDs to repla­ce the failed dri­ve. LVM2 can be used in „par­tial” mode witho­ut all the drives.
  2. To use par­tial mode, You need to cre­ate /dev/ioerror devi­ce like this (I use Ubun­tu, in other distros it might be different): 
    • nano filename to cre­ate a text file whe­re a sin­gle line „0 9999999999 error” sans quotes sho­uld be placed
    • dmsetup create ioerror filename to cre­ate a devi­ce LVM will read inste­ad of mis­sing PV
    • ln -s /dev/mapper/ioerror /dev/ioerror so it’s just whe­re LVM will look for it
  3. After ioer­ror is cre­ated, just acti­va­te your volu­me gro­up in par­tial mode using vgchange -P -ay VOLNAME
  4. Mount it (it will mount in read only mode) and copy your pre­cio­us data

Che­ers to the­se guys who final­ly writ­ten some­thing I could use inste­ad of pvcre­ate and bogus hard dri­ves discussions.