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
Resizing a Physical Volume
If you need to change the size of an underlying block device for any reason, use the pvresize command to update LVM with the new size. You can execute this command while LVM is using the physical volume.
EXAMPLES
Expand the PV on /dev/sda1 after enlarging the partition with fdisk:
Shrink the PV on /dev/sda1 prior to shrinking the partition with fdisk (ensure that the PV size is appropriate for your intended new partition size):
pvresize –setphysicalvolumesize 40G /dev/sda1
RESTRICTIONS
pvresize will refuse to shrink PhysicalVolume if it has allocated extents after where its new end would be. In the future, it should relocate these elsewhere in the volume group if there is sufficient free space, like pvmove does.
pvresize won’t currently work correctly on LVM1 volumes or PVs with extra metadata areas
Preventing Allocation on a Physical Volume
You can prevent allocation of physical extents on the free space of one or more physical volumes with the pvchange command. This may be necessary if there are disk errors, or if you will be removing the physical volume.
The following command disallows the allocation of physical extents on /dev/sdk1.
You can also use the -xy arguments of the pvchange command to allow allocation where it had previously been disallowed.
“pvchange -x n /dev/sdk1″ disallows the allocation of physical extents on this physical volume (possibly because of disk errors, or because it will be removed after freeing it.