How to move / copy logical volume (lv) to another volume group (vg)?
Solution 1:
vgmerge lets you merge two VGs. You can also use pvmove to move data within a VG, and vgsplit if you want to go back to multiple VGs.
Solution 2:
There is no reason to copy it to a .img file first, just do the lvcreate first, then directly copy it over:
lvcreate --snapshot --name <the-name-of-the-snapshot> --size <the size> /dev/volume-group/logical-volume
lvcreate --name <logical-volume-name> --size <size> the-new-volume-group-name
dd if=/dev/volume-group/snapshot-name of=/dev/new-volume-group/new-logical-volume
Solution 3:
Okay, I was able to handle the situation in my own way. Here are the steps I took:
1) Take a snapshot of the targeting logical volume.
lvcreate --snapshot --name <the-name-of-the-snapshot> --size <the size> /dev/volume-group/logical-volume
Note : Size of the snapshot can be as large as or as small as you wish. What matters is having enough space to capture changes during snapshot period.
2) Create an image copy of the snapshot content using dd
dd if=/dev/volume-group/snapshot-name of=/tmp/backup.img
3) Create a new logical volume of enough size in the targeting (new) volume group.
lvcreate --name <logical-volume-name> --size <size> the-new-volume-group-name
4) Write data to the new logical volume from the image backup using dd
dd if=/tmp/backup.img of=/dev/new-volume-group/new-logical-volume
5) delete the snapshot and image backup using lvremove
and rm
respectively.
That's all folks... Hope this helps to someone :)