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
  1. On VM1 – Imaging VM
    • Connect to VM1 as administrator
    • Run sysprep to generalize the image:  sysprep.exe /generalize /oobe /shutdown
  2. 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
  3. 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.
  4. 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
  5. Cleanup all VMs and VHDs other than the extended image
  6. Leave a Reply

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