Azure – increase Linux VM OS Disk size

I am using Azure Linux (Ubuntu) VM’s default OSDisk 30 GB, due to data and other files there was a need emerged to increase that size.

I went to Azure portal and it was straightforward to increase disk size. Shut down VM, alter Disk config to increase size, save and reboot machine.

But surprisingly nothing changed when i checked the size again using df -h

Then i started reading the documentation of Azure and came across below URL (see bottom ref section) which explained that Portal only create / modify size but you still have to do update of partition , modify of filesystem to reflect recent changes.

Also on my /dev/sda i was getting below error

GPT PMBR size mismatch (62914559 != 125829119) will be corrected by w(rite).

started reading on stack blogs and found the reason and solution for this GPT error. As we recently increased the size which was not completely utilized so system was complaining about it.

Below commands i performed to resolve my issue and they are pretty standard what i found when you have to work on Linux fs.

sudo parted

(parted) print
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 62914560 blocks) or continue with the current
Fix/Ignore? Fix

Above have fixed that GPT error

Now you have delete and create new partition and update the partition table.

demong@demomac:~$ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 79027915-3219-49A0-BD9B-9D73DCA28691

Device Start End Sectors Size Type
/dev/sda1 227328 62914526 62687199 29.9G Linux filesystem
/dev/sda14 2048 10239 8192 4M BIOS boot
/dev/sda15 10240 227327 217088 106M EFI System

Partition table entries are not in disk order.

Command (m for help): d
Partition number (1,14,15, default 15): 1

Partition 1 has been deleted.

Command (m for help): n
Partition number (1-13,16-128, default 1): 1
First sector (34-125829086, default 227328):
Last sector, +sectors or +size{K,M,G,T,P} (227328-125829086, default 125829086):

Created a new partition 1 of type 'Linux filesystem' and of size 59.9 GiB.
Partition #1 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: n

Command (m for help): w

The partition table has been altered.
Syncing disks.

Last command which will perform the resize of fs is

demong@demomac:~$ sudo resize2fs /dev/sda1

And you all set

Disk size will start reflecting!!


One Reply to “Azure – increase Linux VM OS Disk size”

Leave a Reply

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