How to Extend LVM Partition with lvextend command in Linux

Resizing the file system size is an important task of Linux admin’s profile. In Linux , LVM(Logical Volume Manager) provides the facility to increase and reduce the file system size. In this tutorial we will discuss the practical examples of lvextend and will learn how to extend LVM partition on the fly using lvextend command.

Scenario : Suppose we have a LVM partition(/home) and running out of space and want to extend or increase file system size. So to increase the size of the file system first we must see whether in volume group has free space or not. If the Volume group has free space then use the below steps :

Step:1 Type ‘ df -h’ command to list the file system

Run the “df -h” command followed by the file system to view total ,used and available disk space

[[email protected] home]# df -h /home/
 Filesystem            Size  Used Avail Use% Mounted on
                       9.7G  9.2G     0 100% /home

As we can see /home is 100 % utilized.

Step:2 Now check whether free space is available space in the volume group

To display volume group details, execute the vgdisplay command followed by volume group name,

# vgdisplay < Volume-Group-Name>

[[email protected] home]# vgdisplay vg_cloud
   --- Volume group ---
 VG Name                      vg_cloud
 System ID
 Format                       lvm2
 Metadata Areas               1
 Metadata Sequence No         4
 VG Access                    read/write
 VG Status                    resizable
 MAX LV                       0
 Cur LV                       3
 Open LV                      3
 Max PV                       0
 Cur PV                       1
 Act PV                       1
 VG Size                      27.01 GiB
 PE Size                      4.00 MiB
 Total PE                     6915
 Alloc PE / Size              5256 / 20.53 GiB
 Free  PE / Size              1659 / 6.48 GiB
 VG UUID                      1R89GB-mIP2-7Hgu-zEVR-5H02-7GdB-Ufj7R4

Step:3 Use lvextend command to increase the size.

Run below lvextend command to extend the file system,

[[email protected] ~]# lvextend -L +2G /dev/mapper/vg_cloud-LogVol00
     Extending logical volume LogVol00 to 11.77 GiB
     Logical volume LogVol00 successfully resized

Above command will extend the file system size by 2GB. You can also specify the size in MB , just replace G with M.

Step:3 Run the resize2fs command

In above step we have executed the lvextend command to extend the file system size by 2 GB but still the file system is not updated, so execute the following resize2fs command

[[email protected] ~]# resize2fs /dev/mapper/vg_cloud-LogVol00

Step:4 Use df command and verify /home size .

Re-run the df -h command followed by /home file system, now we can see that file system has been extended by 2 GB, before the extension size was 10 GB

[[email protected] ~]# df -h /home/
 Filesystem            Size  Used Avail Use% Mounted on
                        12G  9.2G  1.9G  84% /home

Read AlsoHow to setup thin Provisioned Logical Volumes in CentOS 7 / RHEL 7

11 Responses

  1. danny says:

    Thank you very helpfully

  2. Nandkishor says:

    outstanding information….

  3. rino19ny says:

    what about mount points that are multi-path? can you safely extend them?

  4. Monty Cantsin says:

    better use:
    xfs_growfs /dev/mapper/vg_cloud-LogVol00

  5. Sloba says:

    Thank you very much it was very helpful.

  6. Guido says:

    Hi! First of all thanks for sharing this post. I use LVM almost everywhere!
    I would like to add that, you can add a “-r” in the end of the line where you extend the LV. Example:
    # lvextend -L +2G /dev/mapper/vg_cloud-LogVol00 -r

    If you do that, there is no necessity of resize2fs command!

  7. Tri Nanda says:

    Very helpful, thanks Man 🙂

  8. Benina Svilenova says:

    All good, but as an intern sys admin, I was just gonna run resize2fs on an xfs file system. It would be great if you write somewhere in the articl that this is for ext2/3/4 thanks in advance!

  9. geetha reddy says:

    great job!! its was very helpfull. Thank you. 🙂

  10. Mohammadali says:

    very nice , Thank You💚

Leave a Reply to Benina Svilenova Cancel reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest