[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.

7 myśli nt. „[en] How to mount LVM VG and restore data from it when one of its PV drives has failed

  1. Many thanks for this. Your plan to give something back to google worked, and I’ve recovered the files I couldn’t access from my LVM (-1 disk), after the backups had also failed. This is a much simpler solution than the others I’d found elsewhere.

  2. slamfu “It’s still hard to believe only 8 Democrats and 1 Republican voted against the repeal.”Yea, its votes like that that remind me we have a problem not just with the GOP, but many of the spineless dems who are also either bought and paid for by the Wall St. donors or are too stupid to do the right thing.

  3. polgara: a few of them are copyrighted… when i got one like that i just hit “reload” and took the next one!szarek (will): i LIKE it!jenty: yours is very cool!preposterous ponderings: yeah this one did… teeheemalicious intent: i’ll be right there!s.c.g: ‘s awesome when it works out so well! i did a few of them…

  4. إبداع يا محمود، أشكرك!هل من المقرر نشر تلك المذكرات؟ هل توجد مذكرات أخرى يمكن الاستعانة بها للتعرف على ذلك التاريخ؟

Dodaj komentarz

Twój adres email nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *