4

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.

Niklas K.
  • 51
  • 3

3 Answers3

2

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.

mdpc
  • 11,698
  • 28
  • 51
  • 65
  • 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
1

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.

Javier
  • 9,078
  • 2
  • 23
  • 24
1

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.

Niklas K.
  • 51
  • 3