Installation guide

Chapter 5. LVM Configuration Examples
62
In the initial set up, the logical volume mylv is carved from the volume group myvol, which in turn
consists of the three physical volumes, /dev/sda1, /dev/sdb1, and /dev/sdc1.
After completing this procedure, the volume group myvg will consist of /dev/sda1 and /dev/sdb1.
A second volume group, yourvg, will consist of /dev/sdc1.
5.3.1. Determining Free Space
You can use the pvscan command to determine how much free space is currently available in the
volume group.
[root@tng3-1 ~]# pvscan
PV /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 ]
5.3.2. Moving the Data
You can move all the used physical extents in /dev/sdc1 to /dev/sdb1 with the pvmove command.
The pvmove command can take a long time to execute.
[root@tng3-1 ~]# 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 /dev/sdc1 is free.
[root@tng3-1 ~]# pvscan
PV /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 ]
5.3.3. Splitting the Volume Group
To create the new volume group yourvg, use the vgsplit command 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.
You can deactivate the logical volumes with the lvchange command or the vgchange command.
The following command deactivates the logical volume mylv and then splits the volume group
yourvg from the volume group myvg, moving the physical volume /dev/sdc1 into the new volume
group yourvg.
[root@tng3-1 ~]# lvchange -a n /dev/myvg/mylv
[root@tng3-1 ~]# vgsplit myvg yourvg /dev/sdc1