Basically, I want to move / copy several logical volumes (lv) into a new volume group (vg). The new volume group reside on a new set of physical volumes. Does anyone know how to do that safely without damaging to the data inside those logical volumes??
|
|
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. |
|||
|
|
|
There is no reason to copy it to a .img file first, just do the lvcreate first, then directly copy it over:
|
|||||||||
|
|
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.
2) Create an image copy of the snapshot content using
3) Create a new logical volume of enough size in the targeting (new) volume group.
4) Write data to the new logical volume from the image backup using
5) delete the snapshot and image backup using That's all folks... Hope this helps to someone :) |
|||||
|
|
As of the LVM in Debian stretch (9.0), namely 2.02.168-2, it's
possible to do a copy of a logical volume across volume groups using a
combination of Alternatively, you can use A complete self-contained example session using loop devices and
Summary: we create volume group vg1 with logical volume lv1, and vg2 with lv2, and make a copy of lv1 in vg2. Create files.
Set up loop devices on files.
Create physical volumes on loop devices (initialize loop devices for use by LVM).
Create volume groups vg1 and vg2 on /dev/loop1 and /dev/loop2 respectively.
Create logical volumes lv1 and lv2 on vg1 and vg2 respectively.
Create ext4 filesystems on lv1 and lv2.
Optionally, write something on lv1 so you can later check the copy was correctly created. Make vg1 inactive.
Run merge command in test mode. This merges lv1 into lv2.
And then for real.
Then create a RAID 1 mirror pair from
Then split the mirror. The new LV is now lv1_copy.
Make vg2 inactive.
Then (testing mode)
For real
Resulting output:
NOTES: 1) Most of these commands will need to be run as root. 2) If there is any duplication of the names of the logical volumes in
the two volume groups, 3) On merge:
And on split:
|
|||||
|
|
The 4 answers so far all miss that the exact size of the volume often is not known.
MiB is also the default unit for Here why a snapshot is used and what it protects and doesn't protect:
|
||||
|
|