Categories
Uncategorized

Resize Linux osDisk partition on Azure

1) Login to the VM using SSH, we can check the size of the disk by using:
sudo dmesg | grep -i sda

We should see something similar to the output below (assuming you changed the size to 100GB on the portal for the disk):
[    3.100914] sd 2:0:0:0: [sda] 209715200 512-byte logical blocks: (107 GB/100 GiB)

2) To proceed with the partition resize, we will use: sudo fdisk /dev/sda

type: p
this will show partition /dev/sda1

type: d
type: n then p1 (to recreate partition 1) you can accept the default values
NOTE: if you receive a message about deleting or keeping a signature on the disk, just answer N
type: w (to save the new partition)
type: q (to exit fdisk)
sudo reboot (to reboot the VM so the partition is updated)

3) To finalize the resize, after the reboot, execute the command: resize2fs /dev/sda1

4) Use the command: df -h to verify its size:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 99G 698M 94G 1% /

From: https://docs.microsoft.com/en-us/archive/blogs/linuxonazure/how-to-resize-linux-osdisk-partition-on-azure