vgextend Command Examples in Linux

Logical Volume Manager 2 (LVM2) allows you to aggregate physical storage devices into volume groups. You can then divide that aggregated space into one or more logical volumes. Once created, logical volumes can be extended to utilize unused space within the volume group, allowing the file system residing on the logical volume to be extended as well. However, if all of the physical storage in a volume group is already occupied by logical volumes, then more physical volumes must be added before the logical volume can be extended.

The vgextend command is used to dynamically extend the LVM volume group. It increases the capacity of the volume group by adding physical volumes to the volume group. The physical volumes in the LVM volume group can be added when the volume group is created using the vgcreate command, or dynamically added using the vgextend command.

The following are sample steps to extend a Volume Group (VG), a Logical Volume (LV), and a filesystem using a device named /dev/sdN as its Physical Volume (PV).

1. Create a PV from a free disk or partition (e.g. /dev/sdN1 as a partition):

# pvcreate /dev/sdN1

2. Extend the VG (/dev/sdN1 is an existing PV path):

# vgextend vgdata /dev/sdN1

3. Extend the LV and resize the underlying filesystem together (/dev/vgdata/lvdata is the existing LV path), which will be extended by 125 GB:

# lvextend -r -L +125G /dev/vgdata/lvdata

Syntax:

# vgextend [parameter]

Command parameters

  • -A – specify y|n to autobackup metadata.
  • -d – Debug mode
  • -t – Test only
  • -f – override various checks. Use with caution.
  • -q – suppress output and log messages.
  • -y – do not prompt for confirmation
  • reportformat basic|json – Output format to specify.

Examples of vgextend Command

Add the physical volume /dev/sdb1 to the volume group testvg:

# vgextend testvg /dev/sdb1
Related Post