2023 ACHIEVEMENTS

Take a closer look at all the achieved milestones during 2023.

Watch Short Video
  • +357 2425 0808
  • Login
  • English

Home

Blog

How To Extend LVM Disk on Linux Ubuntu 2...

How To Extend LVM Disk on Linux Ubuntu 20.04

How To Extend LVM Disk on Linux Ubuntu 20.04

NetShop ISP

NetShop ISP · Blog Author

Oct 26, 2021 · Technical Tutorials

In this tutorial, we will show you how to extend an LVM disk on your Ubuntu 20.04 Server. Resizing disks is a common yet challenging task for system administrators, when servers are running out usable disk space or when the standard partitioning during installation does not fit their bespoke needs.

What is LVM?

LVM stands for Logical Volume Management. It is a system of managing logical volumes, or filesystems, that is much more advanced and flexible than the traditional method of partitioning a disk into one or more segments and formatting that partition with a filesystem (source: https://wiki.ubuntu.com/Lvm).

LVM consists of 3 main concepts:

  • Physical Volume (PV) – this is the actual disk, i.e. /dev/sda, /dev/sdb, etc.
  • Volume Group (VG) – physical volumes/disks are combined into volume groups, i.e. ubuntu-vg = /dev/sda + /dev/sdb
  • Logical Volume (LV) – a volume group is divided into several Logical Volumes, i.e. ubuntu-vg/root , ubuntu-vg/home, etc.

Information about the PV, VG and LV are important in order to successfully resize our LVM disk.

Step 1. Collect information about current LVM settings and names

To find out the physical volumes (PV) used by the LVM file system, run this command:

sudo pvs

Now we need to find out the Volume group name. Do it by typing this command:

sudo vgdisplay

Next, we will issue the following command to find out information about the Logical Volume:

sudo lvdisplay

As per our example above, we need to make a note of the following useful information:

Our server has one Volume Group named “ubuntu-vg”, which has one Logical Volume “ubuntu-lv”. With this information, we can proceed to extend our disk.

Step 2. Create new Physical Volume (PV)

Whether your Ubuntu 20.04 is a Virtual machine or installed on a Bare-metal dedicated server, you will need to attach/insert the new disk (virtual or physical). Once you do this, we need to configure it within the existing LVM file system.

Type the following command to identify the new disk you have attached:

sudo fdisk -l

Our initial physical volume is named /dev/vda (20GiB) and our newly attached disk (25 GiB) is under the name /dev/vdb.

Another useful command to identify the LVM disk on your server is the following:

sudo lvmdiskscan

We are now good to go to create our new disk as Physical Volume on the server:

sudo pvcreate /dev/vdb

Output: Physical volume “/dev/vdb” successfully created.

Step 3. Add the new Physical Volume (PV) to our Existing Logical Volume (LV)

We will no add our new PV (/dev/vdb) to our existing logical volume. From the first commands in this tutorial, we have noted “ubuntu-lv” as the logical volume name, and “ubuntu-vg” as the volume group name.

Type the command:

sudo vgextend ubuntu-vg /dev/vdb

Output: Volume group “ubuntu-vg” successfully extended.

Now we need to extended the Logical volume as follows:

sudo lvm lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

Your LVM Disk has now been successfully extended. One last command is needed so that the “df -h” output shows the correct size of your file system:

sudo resize2fs -p /dev/mapper/ubuntu--vg-ubuntu--lv

That’s all! We have demonstrated how you can easily extend the LVM file system on your Ubuntu 20.04 Server.

Press Releases
71

Free VPS Trial

No Credit Card Required.

Recent Posts

Navigating Forex Server Hosting: Key Distinctions from Conventional Providers

Navigating Forex Server Hosting: Key Distinctions from Conventional Providers

23 February, 2024

How to Install Nginx, MariaDB, PHP-FPM on AlmaLinux 9 Server (LEMP)

How to Install Nginx, MariaDB, PHP-FPM on AlmaLinux 9 Server (LEMP)

16 February, 2024

How To Reset Forgotten MySQL 5.7 Root Pass in Linux

How To Reset Forgotten MySQL 5.7 Root Pass in Linux

09 February, 2024

4 Things Web Developers Should Know about Virtual and Dedicated Server Hosting

4 Things Web Developers Should Know about Virtual and Dedicated Server Hosting

05 February, 2024

How to Install Docker Compose on Debian 12 Server

How to Install Docker Compose on Debian 12 Server

22 January, 2024

#letushostyou

Award Winning Hosting Provider established in 2004.

120 Faneromenis Avenue, Imperial Tower, 2nd Floor, Larnaca 6031, Cyprus

Products

Bare Metal Servers

Customized Servers

Virtual / Cloud Servers

Forex VPS

Storage VPS

cPanel Web Hosting

Reseller Web Hosting

Colocation

Addons

Premium DNS

Email Hosting

Cloud Backup

DDoS Protection

Licenses

SSL Certificates

Domain Names

Premium SLAs

About Us

Data Center Locations

Looking Glass

Our Company

Contact Us

Careers in Cyprus

Become a Partner

Awards

Certifications

© 2024 S.S. NetShop Internet Services Ltd. All rights reserved.  Terms & Conditions  |  Privacy Policy
CY Reg. Number: HE 217340 | EU VAT Number: CY10217340J

Visa
Mastercard
PayPal
Bitcoin
Tether
Ethereum
Litecoin
Wise
Revolut
Wire Transfer