lvextend – Extend Logical Volume Space

The lvextend command is used to extend the size of a logical volume in Linux. Logical Volumes (LVs) are created by combining multiple physical volumes (PVs) using the Logical Volume Manager (LVM) technology. The lvextend command is used to increase the space available in an LV when it is running out of space.

Overview

The lvextend command is used to extend the size of a logical volume. It can be used to add space to an existing logical volume or create a new logical volume. The syntax for the lvextend command is as follows:

lvextend [OPTIONS] LV PATH

Where OPTIONS are the available options for the command, LV is the logical volume to extend, and PATH is the path to the logical volume.

Examples

To extend the size of an LV by adding 10GB of space, use the following command:

lvextend -L +10G /dev/vg01/lv01

This command will add 10GB of space to the logical volume /dev/vg01/lv01.

To extend the size of an LV by adding all available space in the VG (Volume Group), use the following command:

lvextend -l +100%FREE /dev/vg01/lv01

This command will add all available space in the VG to the logical volume /dev/vg01/lv01.

Options

The following table lists the available options for the lvextend command:

Option Description
-L Extend the logical volume to a specific size.
-l Extend the logical volume by a specific percentage or number of extents.
-r Resize the file system on the logical volume after extending it.
-v Verbose output.
-h Display help information.

Troubleshooting Tips

  • If the logical volume is not mounted, use the resize2fs command to resize the file system after extending the logical volume.
  • If the logical volume is mounted, use the xfs_growfs command to resize the file system after extending the logical volume.
  • If there is not enough free space in the volume group to extend the logical volume, add a new physical volume to the volume group.

Notes

  • The lvextend command can only be used on logical volumes that have been created using LVM.
  • Extending a logical volume does not automatically extend the file system on the logical volume. The file system must be resized separately.