Creating and Managing Volume Groups

The following example creates the volume group myvg from the newly created physical volumes:

sudo vgcreate -v myvg /dev/sd[bcde]

The following output is displayed:

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’
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 An extent, with a default size of 4 MB, is the smallest unit that LVM uses when allocating storage to logical volumes.

The allocation policy determines how LVM allocates extents from either a volume group or a logical volume. The default allocation policy for a volume group is normal, whose rules include, for example, not placing parallel stripes on the same physical volume. For a logical volume, the default allocation policy is inherit, which means that the logical volume uses the same policy as the volume group. Other allocation policies are anywhere, contiguous and cling, and cling_by_tags.

To change allocation policies, use the lvchange or vgchange commands. As an alternative, set a preferred allocation policy directly when creating a volume group or logical volume.

The vgextend and vgreduce commands add physical volumes to a volume group or removes them. The commands enable you to manipulate the size of the volume group.

sudo vgextend | vgreduce [options] vol_group physical_vol

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

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

sudo vgremove vol_group

The command warns you if logical volumes exist in the group and prompts for confirmation.

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.