Using lvextend Command to Increase Logical Volume Size (with examples)

Using lvextend Command to Increase Logical Volume Size (with examples)

Increase a volume’s size to 120 GB

Code:

lvextend --size 120G logical_volume

Motivation:

This use case is beneficial when you want to increase the size of a logical volume to a specific value, such as 120 GB. It can be useful if you have additional disk space available and need to allocate more storage to a specific volume.

Explanation:

  • lvextend is the command used to increase the size of a logical volume.
  • --size 120G specifies the new size for the logical volume, in this case, 120 GB.
  • logical_volume is the name of the logical volume you want to extend.

Example Output:

Size of logical volume logical_volume changed from 80.00 GiB (20480 extents) to 120.00 GiB (30720 extents).
Logical volume logical_volume successfully resized.

Increase a volume’s size by 40 GB as well as the underlying filesystem

Code:

lvextend --size +40G -r logical_volume

Motivation:

This use case is useful when you want to extend both the logical volume’s size and its underlying filesystem. It allows you to automatically resize the filesystem to match the new size of the logical volume.

Explanation:

  • lvextend is the command used to increase the size of a logical volume.
  • --size +40G specifies that the logical volume should be increased by 40 GB.
  • -r flag ensures that the underlying filesystem is resized along with the logical volume.
  • logical_volume is the name of the logical volume you want to extend.

Example Output:

Size of logical volume logical_volume changed from 120.00 GiB (30720 extents) to 160.00 GiB (40960 extents).
Resizing the filesystem on logical volume logical_volume to 160.00 GiB (40960 extents).
Resized and activated logical volume logical_volume successfully.

Increase a volume’s size to 100% of the free physical volume space

Code:

lvextend --size 100%FREE logical_volume

Motivation:

This use case is handy when you want to allocate the maximum available free space in the physical volume to the logical volume. It allows you to utilize all the unused space in the physical volume efficiently.

Explanation:

  • lvextend is the command used to increase the size of a logical volume.
  • --size 100%FREE specifies that the logical volume should use all the available free space in the physical volume.
  • logical_volume is the name of the logical volume you want to extend.

Example Output:

Size of logical volume logical_volume changed from 80.00 GiB (20480 extents) to 200.00 GiB (51200 extents).
Logical volume logical_volume successfully resized.

By utilizing the lvextend command with various options, you can easily increase the size of logical volumes as per your requirements. Whether you need to allocate a specific size, extend both the volume and the underlying filesystem, or utilize all the free space available, lvextend provides the flexibility to manage logical volumes efficiently.

Related Posts

How to use the command 'aws' (with examples)

How to use the command 'aws' (with examples)

The ‘aws’ command is the official CLI tool for Amazon Web Services.

Read More
How to use the command `pkg_delete` (with examples)

How to use the command `pkg_delete` (with examples)

The pkg_delete command is used in OpenBSD to remove packages. It is typically used with the pkg_add and pkg_info commands to manage packages in the OpenBSD operating system.

Read More
How to use the command pageres (with examples)

How to use the command pageres (with examples)

Pageres is a command-line tool that allows users to capture screenshots of websites in various resolutions.

Read More