Sometimes it happens that the disk space allocated to our websites on our server turns out to be too small. If our operating system is installed on LVM (Logical Volume Manager), we can relatively easily expand the disk size to what we need. In this article, I will show you how to do it.
Our working environment:
- Virtual machine running on XCP-ng
- Ubuntu 20.04 Server Edition operating system
- OpenLiteSpeed web server
- CyberPanel management panel
- Disk space based on LVM (Logical Volume Manager)
The 64GB allocated for websites on our server some time ago proved to be too little after a while. After exceeding 80% disk usage, the server slowed down and opening pages became uncomfortable.

What is LVM (Logical Volume Manager)?
LVM is an extremely flexible tool that allows you to conveniently manage disk space on your servers. LVM can be located on different hard disks and different partitions of different capacities, and we can change the size of the disk space on the fly without even having to restart the computer or virtual machine.

Checking hard disk usage
To check the usage of our hard disk, use the df
command with the -h
parameter, which shows the disk size in a human-friendly format.
In the case of our system, the LVM disk size (/dev/mapper/ubuntu-vg-ubuntu-lv
) is 62GB, and 56GB is occupied, which gives 95% disk space usage. This is definitely too little free space for the server to work efficiently. It’s time to allocate more space to the server.
Increasing disk size in XCP-ng
For our virtual machine on which the Ubuntu system with a web server is installed, we have only allocated 64GB, so the first step will be to increase the virtual hard disk for our virtual machine. To perform this operation, we will have to turn off our virtual machine for a while. To do this, we run the XCP-ng center application. Then we select the virtual machine we are interested in, and turn it off. We go to the Storage tab, click on the storage we want to enlarge and click Properties. We select Size and Location and increase the size of the virtual hard disk. Then we can restart our virtual machine.

Checking free space in Volume Group
To display information about our volume groups, type vgs
.
Our volume group is ubuntu-vg
with a new size of 126.50GB and it has 63.25GB of free space. To display more information about the volume group, use the vgdisplay
command.
Here we can see that the space allocated to our volume group is 63.25GB and we have another 63.25GB available, which we can add to our volume group.
Displaying a list of logical volumes
To display our logical volumes, type lvs
.
In our case, the logical volume ubuntu-lv
belongs to the ubuntu-vg
volume group.
NOTE: Remember to replace our volume names with your own when typing commands.
Increasing the size of our logical volume
To assign more disk space to our volume group, we will use the lvextend
command. Remember to replace ubuntu-vg
and ubuntu-lv
with the volumes used in your system.
The -L
parameter allows us to specify the size by which we want to increase our logical volume, in our case we are increasing it by 63.25GB.
Note: Remember that we do not specify units TB, GB, MB etc., but P for Petabytes, T for Terabytes, G for Gigabytes, M for Megabytes etc.
After re-entering the vgdisplay
command, we see in the Alloc PE/Size field that the additional disk space has been correctly allocated.
Enlarging the file system
Our new disk space is not yet visible to the system. We must first enlarge the file system with the resize2fs
command.
By giving the resize2fs
command, we must indicate where our logical volume is mounted, in our case it is /dev/mapper/ubuntu--vg-ubuntu--lv
.
After this operation, our new disk space is already visible to the operating system and CyberPanel. 47% disk usage is a decent result and should be enough for a while.

Summary
As you can see, LVM has many advantages. If you had an operating system installed on normal disks and partitions, you probably would not be able to do without formatting the disks and installing the system from scratch. Whereas LVM allows you to add a new disk to your computer, create a partition on it and add it to an already existing group of volumes and logical volumes. Easy, fast and enjoyable.
If you have any questions about increasing the capacity of LVM volumes, do not hesitate to ask them in the comments.
Leave a Reply