Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.


I have a server with 4 1TB drives in LVM as shown below. The server is a openvz hardware node with a dozen or so openvz containers. At this time each container uses one disk only. This was designed at the time to maintain most control and separation over the disk io load.

# pvdisplay -s
  Device "/dev/sdd1" has a capacity of 227.51 GiB
  Device "/dev/sdc1" has a capacity of 427.51 GiB
  Device "/dev/sdb1" has a capacity of 427.51 GiB
  Device "/dev/sda2" has a capacity of 407.02 GiB

ATM each PV is set up with it's own separate VG:

# vgdisplay -s
  "vg04" 931.51 GiB [704.00 GiB used / 227.51 GiB free]
  "vg03" 931.51 GiB [504.00 GiB used / 427.51 GiB free]
  "vg02" 931.51 GiB [504.00 GiB used / 427.51 GiB free]
  "vg01" 931.02 GiB [524.00 GiB used / 407.02 GiB free]

A number of LV's exist over these VG's:

# lvdisplay | grep Name
  LV Name                /dev/vg04/swap
  VG Name                vg04
  LV Name                /dev/vg04/vz
  VG Name                vg04
  LV Name                /dev/vg03/swap
  VG Name                vg03
  LV Name                /dev/vg03/vz
  VG Name                vg03
  LV Name                /dev/vg02/swap
  VG Name                vg02
  LV Name                /dev/vg02/vz
  VG Name                vg02
  LV Name                /dev/vg01/swap
  VG Name                vg01
  LV Name                /dev/vg01/root
  VG Name                vg01
  LV Name                /dev/vg01/vz
  VG Name                vg01


One container has now grown to a size where I need to split it over two disks in order to handle the load.

Essentially I'd like to merge two LV's - /dev/vg03/vz and /dev/vg04/vz into one LV striped over two disks.

How do I best accomplish that? Would vgmerge be able to do this? The manpage for vgmerge is rather brief and I've not been able to find any more in-depth discussion of it's use.

In the end I could accomplish the objective by moving things around but there is a lot of data in play and these are production servers so I'd rather try to avoid that if possible.

share|improve this question
add comment

3 Answers

Though, you'll be able to merge the two VGs, I don't think you'll be able to convert a LV from linear to striped without first deleting it and recreating it.

In any case, you can easily do tests with loop devices on sparse files that take hardly any disk space:

truncate -s500G a
truncate -s500G b
sudo losetup /dev/loop0 a
sudo losetup /dev/loop1 b
sudo pvcreate /dev/loop0
sudo pvcreate /dev/loop1
sudo vgcreate A /dev/loop0
sudo vgcreate B /dev/loop1
sudo lvcreate ...
share|improve this answer
That wouldn't be too much of a problem, but vgmerge merges an inactive volume group into an active or inactive volume group - so I'd have to inactivate one of the VG's before I can merge them. If I understand right that means the LV's on the deactivated VG becomes unusable and that would be a problem. It would bring me back to square one having to move everything around to be able to accomplish what I want to do. –  Rene Dec 10 '12 at 11:36
add comment

If I'm reading your question correctly, what you really want to do is merge two LV's on separate VG's. This will necessitate you moving data from one LV to another, there isn't a way to merge LVs directly.

So you're looking at some sort of down time.

You can probably limit it, by doing the following: LVA - Soon to be larger Logical volume LVB - Soon to be removed logical volume

  1. rsync LVB to location on LVA (most time-consuming)
  2. ** Downtime Starts ** - Disable remote access
  3. Do final rsync to ensure all data is current on LVA
  4. Unmount LVB
  5. Move rsynced data on LVA to location where it will live as if LVB was mounted (this should be w/in LVA so the mv is just an inode operation and thus very short).
  6. ** Downtime Ends ** - Re-enable remote access
  7. At your leisure, blow away LVB, and vgmerge VGB into VGA
  8. You can then grow LVA (and probably grow the filesystem online also)
share|improve this answer
Yes that was what I meant by "moving things around". The problem is each of these two LV are home to several virtual machines, and this way I would have to first move the content of LV(b) to LV(c), then delete LV(b), merge VG(b) with VG(a), create a new LV(x) striped over two PV's, then finally move the content from LV(a) and LV(c) back to the striped LV(x). Possible but cumbersome. It would have been cool if I could somehow merge the two VG's, create the LV(x) directly and move content, that way I would only have to copy the content once. Consider also these LV's are 300G+ data each. –  Rene Dec 10 '12 at 16:34
add comment

I don't know how to do that without destroying the two logical volumes /dev/vg03/vz and /dev/vg04/vz, and creating a new LV once you've reorganized the space.

The following strategy should (I haven't tested it) let you obtain the desired configuration with no downtime for the other volumes. You may need some temporary space on a scratch disk, up to the size of the largest of the LVs you are deleting.

  1. Back up all data from the two LVs to delete.
  2. Deactivate the LVs (lvchange -an).
  3. Create a physical volume over the scratch space (pvcreate).
  4. Add the scratch space to vg03 (vgextend). Move the extents at the end of vg03 to the scratch space with pvmove /dev/sdXX:MMM-NNN (replace sdXX by the appropriate partition specifier and MMM and NNN by the right extent numbers). Move the extents that you want to convert for use by the new striped LV.
  5. Call pvresize to shrink the physical volume on the volume group where you just freed some space at the end.
  6. Use fdisk or parted to shrink the partition containing the physical volume you just shrank. While you're at it, create a new partition for the rest of the space.
  7. Call pvmove again to move all the data back from the scratch space to its original (now shrunk) PV.
  8. Repeat the previous 4 steps for vg04. After this, you no longer need the scratch space.
  9. There are now two new partitions with nothing on them. Turn them into physical volumes (pvcreate), and create a volume group for these two PVs (vgcreate).
  10. Create a striped LV on the new VG.
share|improve this answer
Thanks, but this seems to be just a (perhaps more detailed) explanation as already discussed in the other replies, with the added need for a scratch disk (which there isn't place for in the server as it already has 4 of max 4 disks installed). –  Rene Dec 11 '12 at 3:43
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.