Increase OS Disk Size of an Azure Linux VM

If you try to expand the disk without stopping/de-allocating the VM, depending on disk config it may not allow your to change the size and a banner with message “Changes to the disk size can be made only when the disk is unattached or the managing virtual machine(s) are deallocated.” would be displayed. To increase the disk size of a Linux VM, you can perform the following:

In my environment, the VM OS disk size was smaller than 4TB and could not be resized using the online method that could be done without downtime(it requires some special configuration which I didnt really get deep into). This method will involve shutting down the VM, de-allocating the VM, increasing the disk and then bringing the disk back online. So, there would be some downtime.
Another thing:

Note: Replace text in blue with your environment specific values.

1. Stop the VM:

az vm stop –resource-group Resource-Group-Name –name VM-NAME –subscription SUBSCRIPTION-ID

2. De-allocate the VM: (This may take a few minutes)

az vm deallocate –resource-group Resource-Group-Name –name VM-NAME –subscription SUBSCRIPTION-ID

3. Increase the Disk (from the UI):

-Navigate to the VM in Azure. Click on “Disks”

 

-Select the disk that you need to resize.

 

Click on “Size + performance” and select the disk size to which you want to increase to and then click on “Save”

4. Start the VM:

az vm start –resource-group Resource-Group-Name –name VM-NAME –subscription SUBSCRIPTION-ID

My Azure VM was based on Ubuntu 20.04.x and did not need additional changes in the OS. After the VM booted backup, it did automatically expand to the new allocated size.

Some of my thoughts on Azure Naming and resizing:
For some wierd reason, Azure does not make things easy for resizing disks. Ideally, you should be able to shutdown the VM and increase the disk, BUT Azure needs you to de-allocate the VM before you can make any changes to the disk. Another strange thing Azure decided to do is to label “de-allocate VM” instead of some sane label as at first it sound as if going to delete the VM and all its data when when in reality it does not.

Sources/References:
https://learn.microsoft.com/en-us/azure/virtual-machines/linux/expand-disks?tabs=ubuntu

If you have any queries/feedback regarding this, feel free to leave a comment below and will get back to you as soon as I can.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.