If you are a system administrator, you should know that sometimes when the standard partitioning during installation does not fit the custom needs of the servers or the servers run out of usable disk space. For this reason, you usually need to change the size of the disks. This article will teach you How to Resize LVM Partition on Ubuntu 22.04. Eldernode offers an economically Ubuntu VPS Server, which you can check out the provided package to purchase it.
Table of Contents
How to Resize LVM Partition on Ubuntu 22.04
In this guide, we will walk you through the process of resizing an LVM (Logical Volume Management) partition on Ubuntu 22.04. LVM allows you to dynamically manage your storage by adding, removing, or resizing partitions without the need to reboot your system. Follow these clever steps to resize your LVM partition efficiently and securely.
Note: This guide assumes you have basic knowledge of the Linux command line interface.
What is LVM Partition?
LVM stands for Logical Volume Manager and is a flexible storage management system available on Ubuntu and many other Linux distributions. You can manage disk partitions, volumes, and file systems in a more dynamic and flexible way compared to traditional partitioning schemes using LVM. It is an advanced method than the traditional method of partitioning a disk into one or more sectors and formatting that partition with a file system.
Resizing LVM Partition on Ubuntu VPS
In the first step, you should collect information about current LVM settings and names. To do this, find out the physical volumes that are used by the LVM file system using the command below:
And run the command below to find out the Volume group name:
Now you can get information about the Logical Volume as shown below:
Note that you need to insert the new virtual or physical disk. Once done, configure the inserted disk within the existing LVM file system.
Then identify the new disk using the command below:
sudo fdisk -l
Next, create a new disk as Physical Volume on the server as shown below:
sudo pvcreate /dev/vdb
The output should be as follows:
Physical volume “/dev/vdb” successfully created.
Now it’s time to add the new Physical Volume to your existing Logical Volume. To achieve this, simply execute the command provided:
sudo vgextend ubuntu-vg /dev/vdb
The output should look something like this:
Volume group “ubuntu-vg” successfully extended.
And extend the Logical volume using the command below:
sudo lvm lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Resize it as shown below:
sudo resize2fs -p /dev/mapper/ubuntu--vg-ubuntu--lv
Lastly, enter the following command to view the correct size of your file system:
LVM is a system of managing logical volumes or filesystems that allows you to manage disk partitions, volumes, and file systems. In this article, we taught you how to resize the LVM partition on Ubuntu 22.04. I hope this tutorial was useful for you and that it helps you to resize the LVM partition on your Ubuntu server. If you have any questions or problems during the process, you can contact us in the Comments section.