You provisioned an Azure Linux VM with a small OS drive. The OS drive is filling up and you want to increase the size of the virtual hard disk. In this article, I will show you how to resize the Azure Linux VM disk by using the ‘Update-AzureDisk’ PowerShell cmdlet.
There is one caveat in the solution: you will have to shut down the VM for a few seconds to resize its disk. Your VM IP address will be changed thereafter.
In order to follow this tutorial, you need to have Microsoft Azure PowerShell installed on your machine.
First, you use Get-AzurePublishSettingsFile to download the .publishsettings file for your Microsoft Azure Subscription.
Next, you use Import-AzurePublishSettingsFile to import the publishsettings file
Once you are in, please use Get-AzureVM to select the Linux VM that you want to shrink or expand its disk size. The ‘-ServiceName’ parameter specifies the name of the cloud service for which to return virtual machine information. The ‘-Name’ parameter specifies the name of the virtual machine.
To find out the current OS Disk size in GB, you can use the ‘Get-AzureOSDisk’ and ‘Get-AzureDisk’ cmdlets as follows. The first command tells the ‘DiskName’ of the OS Disk. The second command tells the ‘DiskSizeInGB’ based on the DiskName. The OS disk in the following example is 30GB.
To resize the OS Disk to 100GB, first shutdown the VM:
Get-AzureVM -ServiceName “bitnami-wordpress-8d82” -Name “bitnami-wordpress-8d82” | Stop-AzureVM –Force
Run Update-AzureDisk to expand the OS Disk from 30 GB to 100 GB (or your desired size which is < 1023 GB)
Update-AzureDisk -DiskName “bitnami-wordpress-8d82-bitnami-wordpress-8d82-0-201602230528360717” -Label “OS” -ResizedSizeInGB 100
The OS disk is successfully resized to 100 GB now.