I have a logical volume spanning several drives. One of those drives (3TB, the largest of the bunch) is dying, and I am currently making an image of it (via ddrescue). I'm not yet sure on how to use this image as a replacement PV though.

The steps I'm currently thinking of are:

  1. Mount image as a loop device, with losetup
  2. pvscan
  3. vgchange -a y

Would, after this procedure, LVM detect the loop device as a PV that's part of my volume group (among the working physical drives), and allow me to access the logical volume as normal?

Everything I've found on LVM images so far seems to be about imaging logical volumes, not physical ones, as I am doing now.

If this didn't work, I would just create an image of the entire logical volume (using the failing drive as a PV), however that would mean leaving the failing drive idle but powered on for hours while ddrescue copies the data on the perfectly working drives, risking more data loss.


What I might do is .... assumming that the LVs within the volume group contain standard filesystems:

  1. Do a standard backup of each LV.
  2. Replace the failing disk
  3. Remake the volume group, and logical volumes from scratch just like was done originally.
  4. Restore each logical volume from the backups.

You might be able to shortcut things for some logical volumes if they do not span physical volumes. The shortcuts would be to create the new logical volume with the exact same parameters so that the location of the internal filesystem data would still be consistent.

  • Thanks, that would work, but a standard LV backup is what I'm trying to avoid - in order to have the failing drive idling as little as possible. – Niklas K. Jan 10 '14 at 19:41
  • You might consider adding in other physical disks to the volume group and mirror the logical volumes contained on the failing disk. – mdpc Jan 10 '14 at 21:33

The file \etc\lvm\lvm.conf is where you can set which kind of devices are probed by pvscan. Just set a suitable pattern that includes your loopback device.


For anyone who might find this later, my image has now been written and lvm is able to use the loop device, as described in the initial question.

  • But how did you get it to detect the loop device? – Michael Hampton Jan 11 '14 at 5:58
  • Just ran pvscan and it found it. I should mention that the entire drive was an LVM PV, it did not contain a partition table or anything else that would get in the way here. – Niklas K. Jan 11 '14 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.