The default OS disk size for most Linux distros in Azure is 30GB and in certain circumstances you may need to increase the size of it. The steps below helps in achieving this.
Note: Before proceeding it’s highly recommended that you backup your Azure VM first. You can do this using Azure Backup or use AzCopy to make a copy of your VHD.
- Login to your Linux VM and check the OS disk size.
- Re-partition the disk using fdisk /dev/sda
- Type “p” to list the current partition details. Note the starting sector
- Once you are in fdisk, delete the / partition (note: you aren’t deleting the data, just altering the partition table). Type “d” and then select the / partition .
- Type “n” to create a new partition. Use p for primary partition. Type 1 to create the first partition. Use the same starting sector and use the desired en sector or accept the default end sector to use the entire disk.
- Make the partition bootable by using “a”
- Type “p” to to ensure all settings are correct and then with “w” write the changes.
- Reboot the server using command reboot
- Once the VM is back online login to it and resize the file system using resize2fs /dev/sdaX to resize the filesystem for CentOS/RHEL 6.x (where X is the partition number you created. In CentOS/RHEL 7.x the command is “xfs_growfs -d /dev/sdaX”. This may take some time to complete.
- Verify the new size with df -h