3

I have 2 lvm partitons on the same volume group and im wondering if i can merge them to one lvm without data loss

the way i know that i have to create a new physical volume and extend the volume group with that new one and then resize the lvm with the new size and in that case i have to lose my data in order to resize

thanks in advance.

  • short answer : you can't. longer: what are your "data" ? is this a filesystem ? you cannot concatenate filesystem as a rule. Nor can you concatenate logical volumes. – Archemar Mar 17 '15 at 13:14
  • ok what about if they are in different Volume Groups – Macnux Mar 17 '15 at 13:16
  • same answer, however if your data are filesystem, you can grow one (if you have room), copy files and directory, and delete the other. – Archemar Mar 17 '15 at 13:18
2

IF, the logical volumes are on different volume groups and you want to merge them, use the vgmerge command:

First, deactivate the volume group that will be merged into another:

[root@host ~]# vgchange -a n vg_to_be_merged

After that, test if there is no inconsistence that will prevent you from merging:

[root@host ~]# vgmerge -t -v dest_vg vg_to_be_merged

Now, do the merge for real:

[root@host ~]# vgmerge -v dest_vg vg_to_be_merged
    Checking for volume group "dest_vg"
    Checking for volume group "vg_to_be_merged"
    Archiving volume group "vg_to_be_merged" metadata (seqno 2).
    Archiving volume group "dest_vg" metadata (seqno 13).
    Writing out updated volume group
    Creating volume group backup "/etc/lvm/backup/dest_vg" (seqno 14).
  Volume group "vg_to_be_merged" successfully merged into "dest_vg"

However, merging LVM volumes will have no magic trick, since they have filesystems on top of them, and a lot of thinkering with data moving and resizing will be needed.

Further Reading:

  • so in all cases i will have to store the data on another disk and till resizing complete – Macnux Mar 18 '15 at 11:40
  • In cases where you want to merge 2 lvs, yes. To merge vgs, is just to use the command above. If you want to do both, you will have to use vgmerge and after that, move data between lvs making resize and shrink – user34720 Mar 18 '15 at 12:56

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.