Discussion:
[linux-lvm] combining two vg's into one
Chris Conn
2004-01-29 03:24:02 UTC
Permalink
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
***@swbell.net http://storm.cadcam.iupui.edu/~cmcgoat
Austin, TX
Ken Fuchs
2004-01-29 05:38:02 UTC
Permalink
Post by 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.
Post by Chris Conn
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 <***@winternet.com>
Christopher Mark Conn
2004-01-29 07:30:02 UTC
Permalink
Post by Ken Fuchs
Post by 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.
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
***@swbell.net http://storm.cadcam.iupui.edu/~cmcgoat
Austin, Texas, USA
Patrick Caulfield
2004-01-29 12:15:01 UTC
Permalink
Post by Christopher Mark Conn
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).
--
patrick
Ken Fuchs
2004-01-29 16:49:02 UTC
Permalink
Post by Patrick Caulfield
Post by Christopher Mark Conn
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.
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.
Post by Patrick Caulfield
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 <***@winternet.com>

Loading...