How to resize the Linux VM OS disk in Azure

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.

  1. Login to your Linux VM and check the OS disk size.
  2. Re-partition the disk using fdisk /dev/sda
  3. Type “p” to list the current partition details. Note the starting sector
  4. 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 .
  5. 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.
  6. Make the partition bootable by using “a”
  7. Type “p” to to ensure all settings are correct and then with “w” write the changes.
  8. Reboot the server using command reboot
  9. 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.
  10. Verify the new size with df -h
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s