Extending the size of an active root filesystem with Linux Logical Volume Management

The fact that Linux Logical Volume Management (LVM) allows one to extend a file system is well known.  In this article, we will go through an example, demonstrating its application on an active root file system.


Most well-known Linux installation tools such as Anaconda, Debian-Installer and Ubiquity, offer LVM as a major choice even in their automatic partitioning options, resulting in a root file system that is installed under LVM.  Thus, this article is potentially relevant for a high percentage of Linux servers in operation today.

The Scenario:

  • You have an active Linux root file system, mounted from an LVM logical volume
  • This file system is running out of space
  • You have a spare, blank hard disk
  • You want to extend your root file system onto the spare disk without interrupting system activity

Preparation: physically install the spare hard disk and check that it is detected by the kernel:


Here, the new disk device is shown as “vda”.  If you have added a new physical disk rather than a virtual disk, you will see the name “sdb”, “sdc” or similar.

Create a partition on the spare disk and give it the type-code for use by Linux LVM:


Note that the entire disk has been given to the new partition.  You may instead specify a smaller proportion of the disk, if that’s all you have available.


You may be using a GUID Partition Table (GPT), in which case you would use the “gdisk” tool instead of “fdisk”.  gdisk has very similar commands to fdisk, but the partition type-codes have 4 hex digits instead of 2.  As with fdisk, the available codes can be listed before specifying them.  The gdisk code for a Linux LVM partition is 8e00.

Check existing physical volumes:


Convert the new partition into an LVM physical volume, and check that the new physical volume has been created:


Check which LVM logical volume and LVM volume group contains your root file system:


Here, we see that LVM volume group “VG00” contains LVM logical volume “LVroot”, which in turn contains an ext4 filesystem that is mounted on /.  The same information can be obtained using the “vgscan”, “vgdisplay”, “lvscan”, “lvdisplay” and “mount” commands in combination.

Check the existing capacity of the LVM volume group:


Here we see that the LVM volume group currently has a capacity (VG Size) of 19.50 GB.

Extend the LVM volume group to include the newly created LVM physical volume:


Check that the LVM volume group is now bigger:


Here we see that the LVM volume group now has a capacity (VG Size) of 31.49 GB.

Check the existing capacity of the LVM logical volume:


Check the existing free space in the root file system:


Extend the LVM logical volume into the extra space now available within the LVM volume group, at the same time also extending the file system contained within that LVM logical volume:


Note that the “–resizefs” option has been used, ensuring that the ext4 file system also expands to fill the newly available space.  This can be done while the file system is in use, and takes a few minutes, depending on how much disk space is involved.

Check the new LVM logical volume size and the amount of free space now in the root file system:


We see that the LVM logical volume has expanded from 18.50 GB to 30.49 GB, and the size of the root file system has grown from 19 GB to 30 GB.

From this point onward, the root file system has its new, expanded capacity.  This demonstrates that, as long as you can install further disks in your server, your LVM-managed file systems need not run out of space.  This is one of the main purposes for which Linux Logical Volume Management was developed.