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

However great LVM is in Linux, allowing one to span single „partition” over several hard drives, if the underlying „drives” are real hard drives and not RAID volumes, You can get pretty fucked when one of those disks fails.

It took me several hours of googling around and trials to find out how to recover as much data as is possible (meaning: all the data that is on remaining disks, the data on failed drive is obviously lost). So let’s try to add a short and working recipe to Google.

  1. You do NOT have to pvcreate any bogus empty PVs with fake UUIDs to replace the failed drive. LVM2 can be used in „partial” mode without all the drives.
  2. To use partial mode, You need to create /dev/ioerror device like this (I use Ubuntu, in other distros it might be different):
    • nano filename to create a text file where a single line „0 9999999999 error” sans quotes should be placed
    • dmsetup create ioerror filename to create a device LVM will read instead of missing PV
    • ln -s /dev/mapper/ioerror /dev/ioerror so it’s just where LVM will look for it
  3. After ioerror is created, just activate your volume group in partial mode using vgchange -P -ay VOLNAME
  4. Mount it (it will mount in read only mode) and copy your precious data

Cheers to these guys who finally written something I could use instead of pvcreate and bogus hard drives discussions.