5

I've 'cloned' a LVM partition using dd over ssh to a remote server(emergency backup...).

On that remote server, is it possible to 'transform' the dd cloned file back into a LVM partition?

Thanks.

PS: I can access the filesystem on the cloned file, but I don't want a solution which includes rsync or something similar.

  • I'm not answering because I'm not sure, but doesn't LVM2 have GUIDs for LVs? In which case they would have to be relabeled... – Michael Lowman Jan 6 '11 at 1:33
  • 1
    "LVM partition" == LV or PV? – womble Jan 6 '11 at 10:35
3

So I think what you would want to do would be one of the following:

  1. Mount the dd image over loopback.
  2. Rewrite a real disk with the dd image and mount it.

Then, you'll want to "redetect" the LVM config by running:

pvscan
vgscan -ay
lvscan

This is what I've done with EBS clones but not dd clones; but hopefully it also works, it's the same theory.

  • Thanks, it worked. However, do you think there is a solution like the one @Joris described in the comments of the first answer? The partition is not a pv but a lv. – Mihai B. Jan 7 '11 at 14:27
  • If the image is a LV, with no partition table, you could mount it through a loopback. But if the image has a partition table, you would have to use kpartx. Either way, there is no need to mount it to dd the image / partition. – Torian Jan 7 '11 at 14:55
2

First of all you should create an LVM that is at least the same size of the original one. Then you can do something like:

local# dd if=/dev/vglocal/lvm-old | ssh remote dd of=/dev/vgremote/lvm-new

And that should do it. If you already have a file with the original lvm on the remote server, then something very similar can be done:

remote# dd if=/path/to/img of=/dev/vgremote/lvm-new

You could also add the option bs to increment the blocksize used by dd, to speed up the process:

# dd if=... of=... bs=131072
  • Can't you losetup the file to a device and then have lvm recognise the pv? – Joris Jan 6 '11 at 6:13
  • If this is a physical volume and just for the purpose of reading its contents, you could. But I dont see the point of it if you have already set up a volume group, in which you can fense this partition growth, take a snapshot, and above all, do not use abstraction layer over abstraction layers, which might result in punitive performance. – Torian Jan 6 '11 at 15:10

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.