6

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.

Mihai B.
  • 118
  • 1
  • 1
  • 4

2 Answers2

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.

jbatista
  • 103
  • 3
Rafiq Maniar
  • 1,120
  • 9
  • 15
  • 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 07 '11 at 14:27
  • 1
    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 07 '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
Torian
  • 2,314
  • 18
  • 10
  • Can't you losetup the file to a device and then have lvm recognise the pv? – Joris Jan 06 '11 at 06: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 06 '11 at 15:10