17.3.2 Creating and Managing Volume Groups

Having initialized the physical volumes, you can add them to a new or existing volume group.

To create a volume group, use the vgcreate command:

# vgcreate [options] volume_group physical_volume ...

For example, create the volume group myvg from the physical volumes /dev/sdb, /dev/sdc, /dev/sdd, and /dev/sde:

# vgcreate -v myvg /dev/sd[bcde]
Wiping cache of LVM-capable devices
Adding physical volume ‘/dev/sdb’ to volume group ‘myvg’
Adding physical volume ‘/dev/sdc’ to volume group ‘myvg’
Adding physical volume ‘/dev/sdd’ to volume group ‘myvg’
Adding physical volume ‘/dev/sde’ to volume group ‘myvg’
Archiving volume group “myvg” metadata (seqno 0).
Creating volume group backup “/etc/lvm/backup/myvg” (seqno 1).
Volume group “myvg” successfully created

LVM divides the storage space within a volume group into physical extents, which are the smallest unit that LVM uses when allocating storage to logical volumes. The default size of an extent is 4 MB.

The allocation policy for the volume group and logical volume determines how LVM allocates extents from a volume group. The default allocation policy for a volume group is normal, which applies rules such as not placing parallel stripes on the same physical volume. The default allocation policy for a logical volume is inherit, which means that the logical volume uses the same policy as for the volume group. You can change the default allocation policies by using the lvchange or vgchange commands, or you can override the allocation policy when you create a volume group or logical volume. Other allocation policies include anywhere, contiguous and cling.

To add physical volumes to a volume group, use the vgextend command:

# vgextend [options] volume_group physical_volume ...

To remove physical volumes from a volume group, use the vgreduce command:

# vgreduce [options] volume_group physical_volume ...

To display information about volume groups, you can use the vgdisplay, vgs, and vgscan commands.

To remove a volume group from LVM, use the vgremove command:

# vgremove volume_group

Other commands that are available for managing volume groups include vgchange, vgck, vgexport, vgimport, vgmerge, vgrename, and vgsplit.

For more information, see the lvm(8), vgcreate(8), and other LVM manual pages.