Removing Physical Volumes from a Volume Group
DESCRIPTION
vgreduce allows you to remove one or more unused physical volumes from a volume group.
To remove unused physical volumes from a volume group, use the vgreduce command. The vgreduce command shrinks a volume group’s capacity by removing one or more empty physical volumes. This frees those physical volumes to be used in different volume groups or to be removed from the system.
Before removing a physical volume from a volume group, you can make sure that the physical volume is not used by any logical volumes by using the pvdisplay command.
If the physical volume is still being used you will have to migrate the data to another physical volume using the pvmove command. Then use the vgreduce command to remove the physical volume:
The following command removes the physical volume /dev/hda1 from the volume group my_volume_group.
# vgreduce my_volume_group /dev/hda1
It’s a good idea to run this option with –test first to find out what it would remove before running it for real.
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...]
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]
More about LVM Components Physical Volumes
Physical Volumes
The underlying physical storage unit of an LVM logical volume is a block device such as a partition or whole disk. To use the device for an LVM logical volume the device must be initialized as a physical volume (PV).
Initializing a block device as a physical volume places a label near the start of the device.
By default, the LVM label is placed in the second 512-byte sector. You can overwrite this default by placing the label on any of the first 4 sectors. This allows LVM volumes to co-exist with other users of these sectors, if necessary.
An LVM label provides correct identification and device ordering for a physical device, since devices can come up in any order when the system is booted. An LVM label remains persistent across reboots and throughout a cluster.
The LVM label identifies the device as an LVM physical volume. It contains a random unique identifier (the UUID) for the physical volume. It also stores the size of the block device in bytes, and it records where the LVM metadata will be stored on the device.
The LVM metadata contains the configuration details of the LVM volume groups on your system. By default, an identical copy of the metadata is maintained in every metadata area in every physical volume within the volume group. LVM metadata is small and stored as ASCII.