Azure VM Disk Resizing
Background
By default, an Azure VM runs on a Managed Disk with a default size of 30 GB. You can dynamically increase the disk size via the Azure Portal. This can be especially useful if SFTP users are uploading large files, because files are first buffered to disk prior to getting copied to Blob.
Check your current disk size
In the Azure Portal, find the Resource of type Disk.
Click on Configuration, and you should see that the Size (GiB) is 30
.
Next, SSH into the VM and run the following command:
sudo df -h
You should see the following output:
/dev/sda1 29G 1.2G 28G 5% /
Save your IP address
Resizing the VM disk size involves stopping the VM. This means you can lose your public IP address.
In the Azure portal, select the Resource of type Public IP address.
Under Configuration, change the Assignment from Dynamic
to Static
.
Click Save.
Stop your VM
Before you can resize your Managed Disk, you have to Stop your VM.
In the Azure portal, go to your Virtual machine and click the Stop button.
Once the VM Status becomes Stopped (deallocated)
, you can proceed.
Note: If you shut down the VM from within the guest OS (i.e. init 0
), the status will be Stopped
.
You will need to click the Stop button from the Azure Portal, which will also deallocate the VM.
Deallocation lets go of handles to resources, such as the public IP.
Increase the VM disk size
Go back to your Disk resource's Configuration page.
You should now be able to edit the Size.
Set this to something large enough to accommodate your users uploads, even if the Storage Account connection were to stop working.
Note: Keep in mind that you can't decrease the size, so don't go too high.
Click Save.
Start your VM
Go back to your VM and click Start
Check your disk size
After the VM has had a chance to spin up, run the command:
sudo df -h
You should now see the following output:
/dev/sda1 58G 1.2G 57G 3% /
In this case, I set the size to 60
, which somehow gets rounded to 58 GB
.