Red Hat Training
A Red Hat training course is available for Red Hat Enterprise Linux
5.3. Splitting a Volume Group
In this example procedure, an existing volume group consists of three physical volumes. If there is enough unused space on the physical volumes, a new volume group can be created without adding new disks.
In the initial set up, the logical volume
mylvis carved from the volume group
myvol, which in turn consists of the three physical volumes,
After completing this procedure, the volume group
myvgwill consist of
/dev/sdb1. A second volume group,
yourvg, will consist of
- Use the
pvscancommand to determine how much free space is currently available in the volume group.
pvscanPV /dev/sda1 VG myvg lvm2 [17.15 GB / 0 free] PV /dev/sdb1 VG myvg lvm2 [17.15 GB / 12.15 GB free] PV /dev/sdc1 VG myvg lvm2 [17.15 GB / 15.80 GB free] Total: 3 [51.45 GB] / in use: 3 [51.45 GB] / in no VG: 0 [0 ]
- Move all the used physical extents in
pvmovecommand can take a long time to execute.
pvmove /dev/sdc1 /dev/sdb1/dev/sdc1: Moved: 14.7% /dev/sdc1: Moved: 30.3% /dev/sdc1: Moved: 45.7% /dev/sdc1: Moved: 61.0% /dev/sdc1: Moved: 76.6% /dev/sdc1: Moved: 92.2% /dev/sdc1: Moved: 100.0%After moving the data, you can see that all of the space on
pvscanPV /dev/sda1 VG myvg lvm2 [17.15 GB / 0 free] PV /dev/sdb1 VG myvg lvm2 [17.15 GB / 10.80 GB free] PV /dev/sdc1 VG myvg lvm2 [17.15 GB / 17.15 GB free] Total: 3 [51.45 GB] / in use: 3 [51.45 GB] / in no VG: 0 [0 ]
- To create the new volume group
yourvg, use the
vgsplitcommand to split the volume group
myvg.Before you can split the volume group, the logical volume must be inactive. If the file system is mounted, you must unmount the file system before deactivating the logical volume.Deactivate the logical volumes with the
lvchangecommand or the
vgchangecommand. The following command deactivates the logical volume
mylvand then splits the volume group
yourvgfrom the volume group
myvg, moving the physical volume
/dev/sdc1into the new volume group
lvchange -a n /dev/myvg/mylv#
vgsplit myvg yourvg /dev/sdc1Volume group "yourvg" successfully split from "myvg"You can use the
vgscommand to see the attributes of the two volume groups.
vgsVG #PV #LV #SN Attr VSize VFree myvg 2 1 0 wz--n- 34.30G 10.80G yourvg 1 0 0 wz--n- 17.15G 17.15G
- After creating the new volume group, create the new logical volume
lvcreate -L 5G -n yourlv yourvgLogical volume "yourlv" created
- Create a file system on the new logical volume and mount it.
mkfs.gfs2 -p lock_nolock -j 1 /dev/yourvg/yourlvThis will destroy any data on /dev/yourvg/yourlv. Are you sure you want to proceed? [y/n]
yDevice: /dev/yourvg/yourlv Blocksize: 4096 Filesystem Size: 1277816 Journals: 1 Resource Groups: 20 Locking Protocol: lock_nolock Lock Table: Syncing... All Done #
mount /dev/yourvg/yourlv /mnt
- Since you had to deactivate the logical volume
mylv, you need to activate it again before you can mount it.
lvchange -a y /dev/myvg/mylv#
mount /dev/myvg/mylv /mnt#
dfFilesystem 1K-blocks Used Available Use% Mounted on /dev/yourvg/yourlv 24507776 32 24507744 1% /mnt /dev/myvg/mylv 24507776 32 24507744 1% /mnt