Extend existing logical volumes

6. Create and Configure File Systems

πŸ“˜Red Hat Certified System Administrator (RHCSA – EX200)


In Linux, Logical Volumes (LVs) are flexible storage units that sit on top of Volume Groups (VGs), which in turn sit on Physical Volumes (PVs). Sometimes, a logical volume may run out of space. Instead of creating a new disk or partition, Linux allows you to extend the size of an existing logical volume dynamically.

This is a common task in IT environments, for example:

  • Expanding storage for a database that is running out of space.
  • Increasing disk space for virtual machines in a virtualization environment.
  • Adding space to a home directory on a server.

1. Check Current Logical Volume Status

Before extending an LV, you need to know:

  • The name of the logical volume.
  • Its size.
  • The free space available in the Volume Group.

Commands to use:

# List all logical volumes
sudo lvdisplay# Check free space in the volume group
sudo vgdisplay

Key points to note:

  • LV Name β†’ the name of the logical volume you want to extend.
  • VG Name β†’ the volume group that contains the LV.
  • Free PE / Size β†’ how much free space is available in the volume group. You cannot extend beyond this.

2. Extend the Logical Volume

You can extend an LV using either absolute size or by adding a certain amount of space.

Option A: Extend by Size

To add a specific size (for example, 10 GB):

sudo lvextend -L +10G /dev/<VG_Name>/<LV_Name>
  • -L +10G β†’ adds 10 GB to the existing size.
  • /dev/<VG_Name>/<LV_Name> β†’ the path to the logical volume.

Option B: Extend to Maximum Available Space

To use all free space in the volume group:

sudo lvextend -l +100%FREE /dev/<VG_Name>/<LV_Name>
  • -l +100%FREE β†’ adds all remaining free extents in the volume group to the LV.

3. Resize the Filesystem

After extending the LV, the filesystem on it must also be resized so the OS can use the new space.

The command depends on the filesystem type:

A. Ext4 Filesystem

sudo resize2fs /dev/<VG_Name>/<LV_Name>

B. XFS Filesystem

sudo xfs_growfs /mount/point
  • For XFS, you specify the mount point, not the device path.
  • You can extend mounted filesystems online without unmounting, which is useful for servers.

4. Verify the Extension

After extending the LV and filesystem, confirm that the new size is reflected:

# Check LV size
sudo lvdisplay /dev/<VG_Name>/<LV_Name># Check filesystem size
df -h

Example Output:

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg1-lv1 30G 15G 15G 50% /data

5. Important Exam Points

  1. Command Options:
    • lvextend -L +size β†’ add specific size.
    • lvextend -l +100%FREE β†’ use all free space.
    • resize2fs β†’ for ext4.
    • xfs_growfs β†’ for XFS.
  2. Order of Operations:
    1. Check LV and VG sizes.
    2. Extend the LV.
    3. Resize the filesystem.
    4. Verify changes.
  3. You can extend mounted filesystems, especially XFS, which is common in modern Linux servers.
  4. Cannot exceed the free space in the volume group.
  5. Always check disk space and free extents before extending.

6. IT Environment Examples

  • Database Server: A MySQL database is filling up /var/lib/mysql. Admin extends the LV to prevent downtime.
  • VM Storage: A virtual machine’s logical disk grows in VMware or KVM. LV is extended so the VM can store more data.
  • Shared Network Storage: Fileserver /data LV extended when team project files grow.

7. Quick Summary Table

StepCommand ExampleNotes
Check LVlvdisplaySee LV size
Check VG free spacevgdisplaySee available space
Extend LV by 10GBlvextend -L +10G /dev/vg1/lv1Add specific size
Extend LV to all free spacelvextend -l +100%FREE /dev/vg1/lv1Use max space
Resize ext4 FSresize2fs /dev/vg1/lv1Must do after LV extension
Resize XFS FSxfs_growfs /dataSpecify mount point
Verifydf -hConfirm new space

βœ… Exam Tip:
The exam may ask you to extend a logical volume and its filesystem. Remember, extending the LV alone does not automatically give you more usable spaceβ€”you must also resize the filesystem.

Buy Me a Coffee