Skip to contentSkip to conversation

combining two vg's into one

linux-lvm Chris Conn 3 participants 5 messages Jan 28, 2004 – Jan 29, 2004

lore
Share & tools
lore

Chris Conn

author
#0 lore raw

I've got 2 vg's on two different partitions on different disks, one is my root vg and the other has /usr, /var and /tmp filesystems. I'd like to keep them on separate disks but use the same vg if I can, but I'm unsure how to combine them. Do I have to move the lv's on disk2 out of their vg or can I just expand the vg on disk1 to include them? The filesystems are all ReiserFS, system is Slackware Linux 9.1.

Thanks for any advice,

=====
Chris Conn
[email protected] http://storm.cadcam.iupui.edu/~cmcgoat
Austin, TX

#1 lore raw
Quoted 5 lines · Chris Conn

I've got 2 vg's on two different partitions on different disks, one is my root vg and the other has /usr, /var and /tmp filesystems. I'd like to keep them on separate disks but use the same vg if I can, but I'm unsure how to combine them.

To keep / on one disk and /usr, /var and /tmp on another disk, one volume group per disk as described above is the best way to do this. There is no advantage to combining the two volume groups together given that one wants to keep logical volumes exclusively on one disk or the other.

Combining the two volume groups into one volume group would allow logical volumes to span the two disks and lvm striping, but that is contrary to the desire to keep each logical volume exclusively on a particular disk.

Quoted 4 lines

Do I have to move the lv's on disk2 out of their vg or can I just expand the vg on disk1 to include them? The filesystems are all ReiserFS, system is Slackware Linux 9.1.

Logical volumes can't be moved between volume groups.

If the physical extents of two volume groups are the same and the limits of the destination group are not exceeded, the two volume groups can be merged using vgmerge(8). Go to step 9 below.

To join two volume groups with unequal logical extents:

1) Back up all logical volumes.
2) Remove all logical volumes in one volume group, preferably the volume group NOT containing /, using lvremove(8).
3) Remove all physical volumes from the volume group to be removed using vgreduce(8).
4) Finally remove that volume group using vgremove(8).
5) Add all physical volumes that were in the removed volume group into the remaining volume group using vgextend(8)
6) Within the remaining volume group, create all logical volumes removed in step 2 using lvcreate(8)
7) Create the desired filesystems for each logical volume created in step 6.
8) Restore from backup each filesystem created in step 7.
9) Modify /etc/fstab and any other configuration files to reflect the volume group name change in the "moved" (removed/recreated) volumes.

Sincerely,

Ken Fuchs <[email protected]>

#2 lore raw
Quoted 12 lines · Ken Fuchs
Quoted 5 lines

I've got 2 vg's on two different partitions on different disks, one is my root vg and the other has /usr, /var and /tmp filesystems. I'd like to keep them on separate disks but use the same vg if I can, but I'm unsure how to combine them.

To keep / on one disk and /usr, /var and /tmp on another disk, one volume group per disk as described above is the best way to do this. There is no advantage to combining the two volume groups together given that one wants to keep logical volumes exclusively on one disk or the other.

Quoted 4 lines

Combining the two volume groups into one volume group would allow logical volumes to span the two disks and lvm striping, but that is contrary to the desire to keep each logical volume exclusively on a particular disk.

Thanks Ken, that's one thing I was wondering, is it better to keep one vg per pv. Sounds like I'm already set up the way I need to be.

--
Chris Conn
[email protected] http://storm.cadcam.iupui.edu/~cmcgoat
Austin, Texas, USA

#3 lore raw
Quoted 7 lines · Christopher Mark Conn

Ken Fuchs <[email protected]> writes:

Thanks Ken, that's one thing I was wondering, is it better to keep one vg per pv. Sounds like I'm already set up the way I need to be.

I don't think so. One of the major points of LVM is that volumes can span physical disks and you can transparently add disks to the systems and grow existing LVs over them.

To merge two Volume Groups, try the "vgmerge" command. The only prerequisite is that they have the same PE size (which is set at vgcreate time).

Signature · 1 line
patrick
#4 lore raw
Quoted 5 lines · Christopher Mark Conn
Quoted 4 lines

Thanks Ken, that's one thing I was wondering, is it better to keep one vg per pv. Sounds like I'm already set up the way I need to be.

Quoted 3 lines · Patrick Caulfield

I don't think so. One of the major points of LVM is that volumes can span physical disks and you can transparently add disks to the systems and grow existing LVs over them.

That is true, but LVM must be configured to the user's desires. In this case, Chris Conn wants / on one physical volume (actually a whole disk) and /usr, /var and /tmp on another physical volume (again a whole disk). The easiest way to ensure that these four logical volumes never span the two disks is to define one volume group per disk. Ideally one would define a single volume group, but then one would have to use pvmove(8) to keep each logical volume on a physical volume.

If Chris needs more flexibility, he can use vgmerge(8), pvmove(8) and optionally vgsplit(8) to get logical volumes where he wants them.

Quoted 3 lines

To merge two Volume Groups, try the "vgmerge" command. The only prerequisite is that they have the same PE size (which is set at vgcreate time).

The sum of the attributes of the two volume groups must also be within the limits of the destination volume group. If any limit is exceeded, vgmerge should refuse to do the merge. Has this requirement changed?

Sincerely,

Ken Fuchs <[email protected]>