Course contentsShow
← Linux
Lesson 661 of 1,8197. Storage Management and Logical VolumesFree lesson

Extending logical volumes online

Increase filesystem size without unmounting or interrupting production services.

Extending Logical Volumes Online

In this lesson, you will learn how to expand your storage capacity while your applications are still running, ensuring your services stay online without interruption.

When your applications demand more disk space, you don't always need to plan for downtime. Because LVM acts as an abstraction layer between your physical drives and your filesystem, it allows you to grow the underlying logical volume while the kernel continues to read and write data to it.

The Two-Step Growth Process

Extending a volume is a two-step procedure: you must grow the container (the logical volume) and then notify the filesystem (the interior contents) that there is new space available to use.

If you have a logical volume named data_vol inside a volume group called vg_storage, you can perform both steps simultaneously using the lvextend command with the --resizefs flag:

sudo lvextend -L +10G /dev/vg_storage/data_vol --resizefs

Here is what happens under the hood:

  1. lvextend: This command instructs the LVM layer to grab an additional 10 Gigabytes from the available space in your volume group and allocate it to your logical volume.
  2. --resizefs: This is the "magic" addition. Instead of forcing you to unmount the volume to run a separate filesystem resize command (like resize2fs or xfs_growfs), this flag automatically detects the filesystem type (ext4, XFS, etc.) and expands it to fill the newly acquired space while the volume remains mounted.

Why This Matters

In traditional partitioning, increasing space often meant unmounting, moving data, or even rebooting—a nightmare for databases or web servers. By using LVM's ability to resize live, you treat your storage as a flexible pool that grows dynamically to meet demand. As long as your volume group has free Physical Extents, your Logical Volumes can grow on demand, keeping your production environment stable and your storage administrators stress-free.

Key Takeaway: By using the --resizefs flag with lvextend, you can seamlessly expand both your LVM logical volume and its associated filesystem without ever unmounting or interrupting your live services.