Expanding C Drive in Windows Azure Virtual Machine (VM)

Sharing is caring!

MS Azure does not offer state forward way to increase C drive size like AWS with snapshot etc. So we need to follow such process, This is lengthy and cumbersome process but works . 
The operation will require one VM to create a base image from the platform image, and then a second VM to modify the 30GB image to something larger.
  1. Deploy 2 VMs using Windows Server 2008 R2 image
  • VM1: Imaging VM
  • VM2: Worker VM
  • On VM1 – Imaging VM
    • Connect to VM1 as administrator
    • Run sysprep to generalize the image:  sysprep.exe /generalize /oobe /shutdown
  • From Azure Portal
    • Note the URL to the VHD for VM1 (from portal under Virtual Machines à Disks)
    • Delete VM1
    • Delete the disk object in the portal for VM1. (This is needed to release the lease on the blob that contains the VHD for VM1)
    • Attach data drive to VM2 that will be used to process the VHD image. This drive should be large enough to hold the original image and the expanded image that you will create. The commands to create an empty data disk are: Virtual Machines àSelect VM à Attach à Attach empty disk
  • On VM2 – Worker VM
    • Connect to VM as administrator
    • Format the data disk
    • Install CloudXplorer or other Windows Azure storage management tool. You will also need to install .NET 3.5 on the VM before installing CloudXplorer.
    • Download the VHD as noted in step 3 above
    • Install a VHD Utility such as VMResizer
    • Use VHD management tool to extend the VHD to the desired size
    • Mount the expanded VHD on VM2 using Disk Management: Disk Management MMC à Action à Attach VHD à Enter path to expanded VHD
    • Use Disk Management MMC to extend the volume to fill out the entire disk.
    • Detach the expanded VHD using the commands: Disk Management MMC à Right-click on disk à Detach VHD
    • Upload the extended VHD back to the blob store as a PAGE BLOB. You could also use CSUpload for this step. CSUpload will be faster, but it is yet another tool that you would need to install on VM2.
  • From Azure Portal
    • Shutdown VM2
    • Detach both data disks that were attached to VM2
    • Delete the disk object in the portal for both the extended image and the data disk
    • Add the extended image back as an image using the commands:  Virtual Machines àImages à Create Image
  • Cleanup all VMs and VHDs other than the extended image
  • Leave a Reply

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