lvextend – Extend the Filesystem using 100%FREE

As data storage needs grow, system administrators often face the challenge of increasing filesystem size on Linux servers. One useful tool for extending logical volumes and their underlying filesystems is lvextend.

In this article, we will look at how to extend the filesystem using the lvextend command with the “100%free” option.

lvextend 100 free

Understanding Filesystems and LVM

First, let’s review some key concepts. A filesystem refers to the logical structure and methods used to store and organize data on a storage device. Common Linux filesystems include ext4, xfs, and btrfs.

LVM (Logical Volume Manager) provides a layer of abstraction over raw storage, allowing administrators to create logical storage volumes that can span multiple disks and be resized.

With LVM, a volume group contains underlying physical volumes. Within this group, you can define flexible logical volumes which are then formatted with filesystems.

Extending a Filesystem with lvextend

The lvextend utility is designed to easily grow these logical volumes and the filesystems on top of them.

Lvextend extends the allocated space without taking down applications or unmounting volumes. This avoids downtime and makes increasing capacity simple.

Let’s walk through an example:

1. Check the existing size of your volume group with the “vgdisplay” command.

# vgdisplay
  --- Volume group ---
  VG Name               vgl
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <24.00 GiB
  PE Size               4.00 MiB
  Total PE              6143
  Alloc PE / Size       6143 / <20.00 GiB
  Free  PE / Size       0 / 0   
  VG UUID               Hhqwxx-Q1x9-Cbx0-SfxF-Ide7-cpaU-Pwgs23

If there is no space left on your volume group (vg), you can add additional storage and increase the size of the volume group (vg).

2. Verify the current size of your logical volume with the lvdisplay command. Here we’ll use a volume called myvol:

lvdisplay vg1/myvol

3. Use the lvextend to increase the logical volume – here we tell it to consume all remaining free space in the volume group with the “100%FREE” option.

lvextend -l 100%FREE vg1/myvol

4. Grow the filesystem to match the new space using the command resize2fs.

resize2fs vg1/myvol

3rd and 4th step can also be combined like below:

lvextend -l +100%FREE -r vg1/myvol

5. Then to confirm, you can run the “df” command to verify that the filesystem has been increased

df -h /data

This shows how to use lvextend command in Linux to increase the size of your filesystem. The key benefit of lvextend – it seamlessly extends both the logical volume and underlying filesystem.

The 100%FREE option also optimizes usage of the full volume group.

Conclusion

Lvextend is a simple but powerful tool for increasing filesystems sizes on Linux servers. Combined with LVM, it enables efficient storage management without disruption.

When storage space runs short, lvextend offers an easy path forward by expanding logical volumes to maximize available capacity. With a few quick commands, system administrators can add significant space and put off more difficult upgrades down the road.

Buy me a coffeeBuy me a coffee

Add Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.