Expanding Virtual Hard Disks with Hyper-V

by Daniel Petri - January 6, 2009

One of the most frequent questions I see on forums and newsgroups that deal with virtualization is the age-old question of "I have used all the space inside a VHD hard disk. How do I expand the virtual hard disk to make room for additional data?". Luckily for us, with Microsoft Hyper-V on Windows Server 2008, this is now possible. Hyper-V now adds the ability to increase the maximum size of a virtual hard disk.  Expanding the disk increases the storage capacity of a dynamically expanding virtual hard disk or a fixed virtual hard disk.

Before using the ability to expand the VHD hard disk you must take the following issues into consideration:

    • You must first completely shut down the virtual machine. You cannot expand a virtual hard disk that is associated with a running or saved stated virtual machine.
    • If you expand a virtual hard disk that is associated with a virtual machine that has snapshots, these snapshots will be invalidated. If you need the snapshots, you'd better make sure you plan ahead of time, and/or create new snapshots after performing the expansion of the hard disk.

Make sure no snapshots are associated with this VM.

    • After expanding the virtual hard disk there will be an empty space at the end of the virtual hard disk, just like not using the entire disk when you've originally created partitions in it.  You will either need to create a new partition to use the new space, or expand an existing partition into the new space.

Note: Expanding or extending partitions on Windows Vista and Windows Server 2008 is easier than on Windows Server 2003 or Windows XP, and is performed by using either the Disk Management snap-in from the Computer Management tool, or by using the DISKPART command. Please read my How to Extend a Disk Partition in Windows Vista and Server 2008 article for more information.

Follow these steps to expand VHD hard disks:

    1. Open the Hyper-V management tool from the Administrative Tools folder (or by typing virtmgmt.msc in the Run command).
    2. Start the Edit Virtual Hard Disk wizard by selecting Edit Disk...

    1. If the Before you begin window appears, click Next.

    1. Select the virtual hard disk you want to expand. Click Open and then Next.

    1. Select Expand on the Choose Action page and then press Next.

    1. Enter the new size of the virtual hard disk that you want and then press Next.

    1. In the final screen, press Finish.

  1. Wait till the operation finishes, which should be quite fast.

Next, after booting the VM, use Disk Management snap-in from the Computer Management tool, or by using the DISKPART command to expand the partition within Windows. While possible in Windows Server 2008 and Windows Vista, unfortunately, in Windows 2000/XP/2003, you cannot use the built-in tools to expand the System Partition (the one the Windows operating system is installed on). For these versions you will need to use of these free partition utilities.

Recent Windows Server 2008 Forum threads

Got a question? Post it on our Windows Server 2008 forums!



Join The Petri Insider - Weekly IT Tutorial and Tips, Whitepaper and Webinars