search
top

How To Extend GPT Drive on Ubuntu Server

How To Extend GPT Drive on Ubuntu Server

Recently ran into an issue with adding space to GPT RAW formatted disk on Ubuntu Server 22.04 LTS. The drive was not a standard LVM format. The steps below describe the process to extend the GPT drive.

Step By Step

Login to the server and become root. If you do not or cannot become root just add sudo in front of all the commands in the post.

Type sudo su –
Run the command fdisk -l to force a scan of the disk for the added space will see an error like below. If you do not get the error you may have to reboot the server.

gpextend1

Next we need to find where our root drive “/” lives. Run lsblk -fs

gptext2

We see that ubuntu–vg-ubuntu–lv is the root partition on /dev/sda3 which has “/”

Update the GPT / MBR partition table using fdisk. I will use an emulated disk /dev/loop3 to demonstrate the whole process. Don’t worry, you won’t loss your data under normal circumstances. These commands will only modify the partition table, but make sure DO NOT remove the LVM’s signature, otherwise the system may no longer recognize your LVM PV.

Next update size by running fdisk /dev/sda

gptext3

Next display the partitions type p

gptext4

Partition 3 is the drive we are now going to delete. type d when prompted for the partition type 3

gptext5

Now create a new partition. Type n and press enter to accept 3 for the partition.

gptext6

You will get a warning that this is LVM2_member answer n.

gptext7

Check to see if the partition looks good. Type p

gptext8

Write the changes, type w

gptext9

Next we need to inform the OS of partition table changes. Type partprobe

gptext10

Next resize the physical volume. Type pvresize /dev/sda3

gptext11

Check the physical volume and we see it knows about the size change. Type vgs

gptext12

Next step is to extend the LVM to use all the free space. Type lvextend -l +100%FREE /dev/mapper/ubuntu–vg-ubuntu—lv

gptext13

Check the volume group and see no free space. type vgs

gptext14

Next we need to resize the filesystem. Type resize2fs /dev/mapper/ubuntu–vg-ubuntu—lv

gptext15

We are now complete, type df -h to see the new drive and size.

gptext16

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

top