In this blog post, I will show you how I increase the size of my Linux CentOS Azure VM OS disk size.
By default, Azure Linux VM comes with a 30GB Operating System (OS) disk size.
Step 1 – Stop VM
My first step will be stopping the VM and increasing the disk space.
Step 2 – Increase OS disk space
To increase the disk space of my OS disk, I will click on Disks and click on the OS disk.
I will increase it from 30GB to 35GB.
Step 3 – Start VM
After the resize is completed I will restart the VM.
Step 4 -Connect using SSH and Check size before the change
I will connect to the VM using SSH and use the following command to check the current size.
As you can see I am using 30G partition for (/dev/sda2)
Note: To check the size of the off all the disks and partitions on the VM I run:
Azure CentOS VMs are using /dev/sda disk by default with 2 partitions /dev/sda and /dev/sda2.
The OS partition sits on /dev/sda2 and this is the partition I’m going to resize.
Step 5 – Check partitions on Disk
To check all the partitions on the dev/sda I will run the following command.
fdisk -l /dev/sda
In my case, I need to increase the 2nd partition (sda2)
Now, I will use the fdisk utility to delete the sda2 partition and create a new one with a larger size.
Note: No data will be lost.
I will run the following command to work with the /dev/sda disk.
I will type p
Next, I will type d to delete the 2nd partition (/dev/sda2)
Now, I will type n and create a new partition with a larger size.
From the two option, I will type p for new primary partition.
For the first cylinder, I can type a value or use the default which is 64.
Note: the value (64) is shown in the 3rd screenshots above.
I will type w to write the changes
I will restart the VM using
Step 6 – resize
After the VM is up, I will ssh to it and run the following command.
To check the new size, I will type.
To view all the disk and partitions after the change I will type.
One response to “Resize Azure Linux CentOS 7 VM OS Disk”
[…] contributor to Cloud and DevOps Blog explored what’s involved in increasing the size of Linux CentOS Azure VM disk sizes. In […]