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″.
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...]
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.
Displaying Physical Volumes
There are three commands you can use to display properties of LVM physical volumes: pvs, pvdisplay, and pvscan.
The pvs command provides physical volume information in a configurable form, displaying one line per physical volume.
The pvs command provides a great deal of format control, and is useful for scripting.
For information on using the pvs command to customize your output,
The pvdisplay command provides a verbose multi-line output for each physical volume. It displays physical properties (size, extents, volume group, etc.) in a fixed format. The following example shows the output of the pvdisplay command for a single physical volume.
# pvdisplay
— Physical volume —
PV Name /dev/sdc1
The pvscan command scans all supported LVM block devices in the system for physical volumes.
The following command shows all physical devices found:
# pvscan
PV /dev/sdb2 VG vg0 lvm2 [964.00 MB / 0 free]
PV /dev/sdc1 VG vg0 lvm2 [964.00 MB / 428.00 MB free]
PV /dev/sdc2 lvm2 [964.84 MB]
Total: 3 [2.83 GB] / in use: 2 [1.88 GB] / in no VG: 1 [964.84 MB]