WinCoder Blog

How to resize OS Disk for Linux VM in Microsoft Azure with CloudXplorer

Microsoft Azure allows for deploying a variety of stock Linux Images  from the virtual machine gallery.  There is a wide selection to choose from but you will notice that the OS disk that is created when using these templates may not be sufficient for your needs.  Here is how you can resize the OS Disk for your Linux VM in the new Azure Portal.

If you feel lost following the screenshot from within the Azure portal, you can follow the breadcrumb path at the top of the picture to ensure you are in the right pane 🙂

Ingredients:

CloudXplorer from ClumsyLeaf Software (trial edition works)

Steps:

  1. Select a Linux VM Image to Deploy

deploy vm

2. Deploy Linux based VM in Microsoft Azure

createvm

3. Create DNS to simplify remote access (optional)

CreateDNS

4. Remote into VM over SSH and run df -h to view disk size and utilization of deployed VM

Note: OS disk/dev/sda1 is currently 27G

7dfhOrig

5. Stop the Deployed VM (this will allow us to break the lease the VM has on the vhd containing the OS disk)

5_stopvm

6. Locate storage account for your VM and note the Blob properties indicate the VHD holding the OS disk is currently leased

BlobPropertiesOrig

7.  Find the credentials for your storage account

AccessKeys

8.  Open Cloud Explorer and add a new Azure Blobs account

6addAzureBlobAcct

9. Apply credentials from Step 7

9. addaccttoCloudExplorer

10. Right-click on the VHD containing the OS Disk

ExpandVirtualDisk

11. Break the lease to allow modification

breakthelease

12. Right-Click again to expand the Virtual Disk to the  desired size

resize

13. Note that the Blob Properties now reflect the new size

BlobPropertiesUpdate

14. Restart the VM

restartVM

 

15. After successfully starting, the Blob Properties should now reflect a new lease with status of “Locked”

BlogPropertiesAfterAcquireLease

16. Remote into VM again and check size.

Depending on the image you may need to run:

sudo resize2fs /dev/sda1

Newer kernels automatically resize to available disk.  This was the case with Ubuntu 16.04.

Note that /dev/sda1 is now 77G

FinaldfhUpdate

 

Happy Hacking!


Leave a Reply

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