Displaying Volume Groups
There are two commands you can use to display properties of LVM volume groups: vgs and vgdisplay.
The vgscan command, which scans all the disks for volume groups and rebuilds the LVM cache file, also displays the volume groups.
The vgs command provides volume group information in a configurable form, displaying one line per volume group. The vgs command provides a great deal of format control, and is useful for scripting.
The vgdisplay command displays volume group properties (such as size, extents, number of physical volumes, etc.) in a fixed form. The following example shows the output of a vgdisplay command for the volume group new_vg. If you do not specify a volume group, all existing volume groups are displayed.
# vgdisplay new_vg
— Volume group —
VG Name new_vg
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 11
VG Access read/write
VG Status resizable
DESCRIPTION
vgdisplay allows you to see the attributes of VolumeGroupName (or all volume groups if none is given) with it’s physical and logical volumes and their sizes etc.
vgs (8) is an alternative that provides the same information in the style of ps (1).
Adding Physical Volumes to a Volume Group
To add additional physical volumes to an existing volume group, use the vgextend command. The vgextend command increases a volume group’s capacity by adding one or more free physical volumes.
The following command adds the physical volume /dev/sdf1 to the volume group vg1
DESCRIPTION
vgextend allows you to add one or more initialized physical volumes ( see pvcreate(8) ) to an existing volume group to extend it in size.
Examples
“vgextend vg00 /dev/sda4 /dev/sdn1″ tries to extend the existing volume group “vg00″ by the new physical volumes (see pvcreate(8) ) “/dev/sdn1″ and /dev/sda4″.
Creating Volume Groups in a Cluster
You create volume groups in a cluster environment with the vgcreate command, just as you create them on a single node.
By default, volume groups created with CLVM on shared storage are visible to all computers that have access to the shared storage. It is possible, however, to create volume groups that are local, visible only to one node in the cluster, by using the -c n of the vgcreate command.
The following command, when executed in a cluster environment, creates a volume group that is local to the node from which the command was executed. The command creates a local volume named vg1 that contains physical volumes /dev/sdd1 and /dev/sde1.
vgcreate -c n vg1 /dev/sdd1 /dev/sde1
You can change whether an existing volume group is local or clustered with the -c option of the vgchange command.
You can check whether an existing volume group is a clustered volume group with the vgs command, which displays the c attribute if the volume is clustered.
EXAMPLES
To create a volume group named test_vg using physical volumes /dev/hdk1, and /dev/hdl1 with default physical extent size of 4MB:
vgcreate test_vg /dev/sdk1 /dev/sdl1
Creating Volume Groups
To create a volume group from one or more physical volumes, use the vgcreate command. The vgcreate command creates a new volume group by name and adds at least one physical volume to it.
DESCRIPTION
vgcreate creates a new volume group called VolumeGroupName using the block special device PhysicalVolumePath previously configured for LVM with pvcreate(8).
The following command creates a volume group named vg1 that contains physical volumes /dev/sdd1 and /dev/sde1.
vgcreate vg1 /dev/sdd1 /dev/sde1
When physical volumes are used to create a volume group, its disk space is divided into 4MB extents, by default. This extent is the minimum amount by which the logical volume may be increased or decreased in size. Large numbers of extents will have no impact on I/O performance of the logical volume. You can specify the extent size with the -s option to the vgcreate command if the default extent size is not suitable.
EXAMPLES
To create a volume group named test_vg using physical volumes /dev/hdk1, and /dev/hdl1 with default physical extent size of 4MB:
vgcreate test_vg /dev/sdk1 /dev/sdl1
Removing Physical Volumes
If a device is no longer required for use by LVM, you can remove the LVM label with the pvremove command. Executing the pvremove command zeroes the LVM metadata on an empty physical volume.
If the physical volume you want to remove is currently part of a volume group, you must remove it from the volume group with the vgreduce command.
# pvremove /dev/ram15
Labels on physical volume “/dev/ram15″ successfully wiped
DESCRIPTION
pvremove wipes the label on a device so that LVM will no longer recognise it as a phys?ical volume.
pvremove
[-d|--debug]
[-f[f]|–force [--force]]
[-h|-?|--help]
[-t|--test]
[-v|--verbose]
[-y|--yes]
[--version]
PhysicalVolume [PhysicalVolume...]