Resizing an Azure VM vhd file

UPDATE (09SEP2013): There's a faster way.  See:

I got into a bit of a predicament where the C drive of the VM I created here started to fill up.  I needed to install some software that only gave me the option to install to the C drive.  The installer was telling me there wasn’t enough disk space.  Here’s what I did to increase the size of the OS disk of my Azure VM:

  • Delete the VM
  • Download the .vhd
  • Resize the downloaded .vhd
  • Delete the original .vhd from blob storage
  • Upload the resized .vhd
  • Recreate the VM
  • Use diskpart to get access to the unallocated part of C

Delete the VM


Download the .vhd

Cloud Storage Studio is my favorite storage tool for Windows Azure.  If you’d prefer a free option, then my next favorite is Azure Storage Explorer.  Use one of these to download the .vhd file.  This part is going to require a local hard drive with lots of disk space.  You will need at least 2x the size of the original VHD + the size you want to grow it by.  A fast internet connection will be a big advantage here as well.

Resize the downloaded .vhd

You can use Hyper-V Manager to resize your .vhd file:


My challenge was that the PC with the disk space necessary to store the downloaded and expanded .vhd wasn’t Hyper-V capable.  Therefore, I used a tool called VHD Resizer from here.  There is a nice walkthrough of how to use it here.

Delete the original .vhd from blob storage


Upload the resized .vhd

You need to upload the resized .vhd back to blob storage.  I figured out how to upload it correctly after reviewing Step 5 from the Creating and Uploading a Virtual Hard Disk that Contains the Windows Server Operating System instructions.  However, the command line switches for csupload.exe need to look like this:

csupload Add-Disk –Destination “<full blob url you want for your vhd>” –Label “<whatever you want>” –LiteralPath “<path to resized .vhd>” –OS Windows

Recreate the VM

I created a new VM via the management portal and pointed it to the .vhd file I uploaded with csupload.  In my case, I had to re-attach an additional .vhd drive since my original .vhd was configured with an F drive where my database files were stored.  Once your VM boots up, log in using Remote Desktop.  For me, all of my SQL Server 2012 databases were in a recovering state.  Not sure why.  After I rebooted my server, everything was fine. 

Use diskpart to get access to the unallocated part of C

Your C drive will still report the old size in Windows Explorer.  You need to claim the additional unallocated space in the expanded drive.  To do this, open a command prompt and execute the following series of commands in italics:


Next execute:

list disk

Make sure you select the os disk.  For me, it was disk 0:

select disk=0

Find the partition that needs extending:

list partition

Select the partition.  For me, it was partition 1:

select partition=1

Finally, extend the partition:


Now, you have the additional space in the drive you need to install more stuff Smile.


Comments (2)

  1. Mert says:

    I hope Windows Azure will provide an easier solution for this (like AWS).

    Uploading/Downloading takes too much time. Do you know what would be the solution if you want less downtime?

  2. To get less downtime I create another VM in Azure VM and do the resize on that machine.  Since the file is only being moved within the Azure data center the download is pretty fast.  The upload still takes some time, but it's probably faster than doing it from your client.

Skip to main content