File System Extension with LVM

Video Tutorial


When running the 'df' command on a TLFDS dedicated server, you will see output such as the following:

[root@hsds100 ~]# df -h

Filesystem                   Size  Used Avail Use% Mounted on

/dev/mapper/vg00-lvroot      4.0G  825M  3.0G  22% /

/dev/mapper/vg00-lvhome      1.0G  30M  1.0G    1% /home

/dev/mapper/vg00-lvopt      1008M   34M  924M   4% /opt

/dev/mapper/vg00-lvtmp      1008M   37M  920M   4% /tmp

/dev/mapper/vg00-lvusr       4.0G  1.2G  2.7G  30% /usr

/dev/mapper/vg00-lvusrlocal 1008M   72M  885M   8% /usr/local

/dev/mapper/vg00-lvvar       4.0G  2.0G  1.8G  54% /var

When tallying up the free space among the mount points, you'll notice the server appears to have much less free space than you may have ordered.  Why?

The Linux Fix does not presume to know how your dedicated server will be used, so we configure your server with a base file system layout and allow you to allocate your remaining disk space as you see fit.

All modern Linux distributions leverage LVM, which stands for Logical Volume Management.   Instead of physically partitioning hard disks like in the old DOS and Windows days, LVM uses the entire disk up front then divides up the space virtually, "on the fly".   This has enormous advantages over physical hard disk partitioning.   For instance if your /home directory is getting full and your physical hard drive space is exhaused, LVM allows you to add a second hard drive and "add" it to your existing /home directory without reformatting or reinstalling.   Operations like this can even be done while the server is running and serving content.

LVM Terms
  • Physical Volume:   A physical disk or any type of storage media
  • Volume Group:   A "bucket" containing any number of physical volumes.  Physical volumes can be added and removed to volume groups at any time.
  • Logical Volume:   A slice of space carved from a Volume Group.   Logical volumes are dynamic, meaning they can be grown and shrunk "on the fly".
  • File System:    The final part of the LVM stack, the filesystem is formatted "into" the logical volume and is what is ultimately mounted up on your Linux dedicated server to a mountpoint such as /home, /var, etc.

Common LVM operation:  Extending a file system

As an example, let's say your /home directory is getting full and you would like to extend it by another 10GB.

1)  First, let's verify /home is full:
[root@hsds100 ~]# df -h /home

Filesystem                   Size  Used Avail Use% Mounted on

/dev/mapper/vg00-lvhome      1.0G  1.0G  0M    100% /home

2) Next, let's verify there is free space in the Volume Group to pull 10G from:

[root@hsds100 ~]# vgdisplay

  --- Volume group ---

  VG Name               vg00

  System ID             

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  13

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                9

  Open LV               9

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               698.31 GiB

  PE Size               4.00 MiB

  Total PE              178768

  Alloc PE / Size       37888 / 148.00 GiB

  Free  PE / Size       140880 / 550.31 GiB

  VG UUID               IPrPEd-N5sH-VTVh-IwaB-jjwT-479F-CdtjqL

Plenty of space!  We have 550GB free.

3) Now, let's extend the Logical Volume for /home another 10 gigs.
Note we used the same path as shown from the "df" command in step 1.

[root@hsds100] lvextend -L +10G /dev/mapper/vg00-lvhome

  Extending logical volume lvhome to 11.00 GiB


  Logical volume lvhome successfully resized

4) Finally, we extend the file system to fill the now-larger Logical Volume container.  
Note, this can be done even while the file system is in use!

[root@hsds100] resize2fs /dev/mapper/vg00-lvhome
resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/mapper/vg00-lvhome is mounted on /home; on-line resizing required


old desc_blocks = 1, new_desc_blocks = 1


Performing an on-line resize of /dev/mapper/vg00-lvhome to 2621440 (4k) blocks.


The filesystem on /dev/mapper/vg00-lvhome is now 2621440 blocks long.

5) Let's view our new, larger /home mount point:

[root@hsds100 ~]# df -h /home

Filesystem                    Size  Used Avail Use% Mounted on

/dev/mapper/vg00-lvhome      11.0G  1.0G  10G    1% /home

Was this answer helpful?

 Print this Article

Also Read

Installing the Management SSL-VPN Client

InstallationThe SSL-VPN client downloads are available via the Client Portal (Support ->...

Are your servers "Managed"?

In the dedicated server market, there is no strict definition as to what a "managed" and...

Checking Free Memory (RAM)

Video TutorialOverviewThere are a few commands you can use to check free memory on your Linux...

Is Windows available on the TLFDS Servers?

TLF does not offer Windows as a supported operating system on our TLFDS and zVPS products....

Bandwidth overage calculation

Bandwidth overage is calculated on the last day of the calendar month at a rate of $90 per...