From time to time we are going to be involved in situations where one of our XFS partition is running out of space, but thankfully as good sysadmins, we created this partition from a Logical Volume and there is plenty of free space in the Volume Group to expand both Logical Volume and the XFS partition,


One of the benefits of using XFS with LVM is that we are able to increase both without unmounting the partition, which is just great, just follow this simple guide to learn how to do so,

Let me show you first how to create an XFS partition using LVM, if you already know this, go ahead and skip this part.


Make sure we have an available disk, in this case, we are going to use /dev/sdb



It is time to create the partition that is going to be used as LVM


fdisk /dev/sdb


This is the options that we are going to select for the LVM partition creation.

n (new partition)

p (print partition table)

Hit Enter three times



At this point, our partition has been created but we need to change the ID to 8e which correspond to LVM


t (Change a partition’s system id)

L (List know partition types)

8e (Linux LVM)



Finally, we save the configuration and make sure to update the kernel partition table with this newly created one.


p (Print partition table)

w (Write table to disk and exit)

partprobe /dev/sdb
fdisk -l /dev/sdb


Time to create the Logical Volume, I’ll walk you through the steps.


Here are the commands you are going to enter

# pvcreate partition
# vgcreate vg-name pv-name
# lvcreate -n lv-name -L size M/G/T vg-name
# mkfs.xfs lv-path

With our information:

# pvcreate /dev/sdb1
# vgcreate jorvg /dev/sdb1
# lvcreate -n jorlv -L 10G jorvg
# mkfs.xfs /dev/jorvg/jorlv




Let’s create a folder and mount our new file system:

# mkdir /var/jorlv
# mount -t xfs /dev/jorvg/jorlv /var/jorlv/
# df -h


Time to increase the XFS partition, let’s assume that our partition is full or almost full, (for this example I have created dummy content and occupied around 8.8G of information, imagine that this is a database that is 24/7 running and a bad administration some did not prevent that the date could growth this much.



In order to save the day we are going to increase the Logical Volume by 2 without unmounting the filesystem using the command lvextend and with the -r options to extend the XFS file system.


# lvextend -l extent-value LVM-Path -r
lvextend -L +10G /dev/jorvg/jorlv -r



Yep, it was that easy,


Hope you enjoyed it,



Buy me a coffeeBuy me a coffee