Sign In
   Developer Productivity PKGs
Enterprise Web Apps
IBM i w/ smartclient Solutions

Expanding Almost Any Virtual Hard Disk (including Windows Server 2003) under Windows Hyper-V

the Essence

This technical article outlines the steps required for extending the C: drive of a Windows Server 2003 R2 virtual machine running under Windows Server 2012 R2 Hyper-V.  Please note you can also use this identical technique for expanding Windows 7 and Windows 10 virtual machines running under Windows Server 2012 R2 Hyper-V and later. 

However, this technique is only applicable for expanding the C: drive, if it contains the OS and registry, and only if there is no D (or subsequent) drive space allocated following the C: drive. 

Here are the main components required:
  • a server running Windows 2012 R2 Hyper-V role (or later such as Windows Server 2016 or Windows Server 2019 (recommended))
  • DISKPART.exe utility program, included in Windows Server 2012 R2

Why are we here?

Snug is the word for these digs
  • A virtual hard disk (a .vhd or .vhdx file) is running out of space or has grown to a point where there isn't enough space to install new programs, perform Windows Updates or write database records

  • You want to learn about new capabilities that are gained through the use of virtualization techniques.  For example:

  • by using this technique to expand the size of the C: drive, concerns for running out of space are reduced.  Therefore it is no longer necessary to consider allocating a maximum potential size (when setting the initial size of a new virtual machine C: drive).

  • you can toggle between fixed and dynamic sized disks (by changing settings (for the most part)).  Thus, it is easier to research whether fixed sized disks result in significantly better performance in your configuration (and are worth the additional overhead involved in storing and backing up (copying) the larger .vhd and .vhdx file sizes).  However, the steps to do this are no longer covered in this technical article due to the differences in Hyper-V 2012 R2 (although easier) as opposed to Microsoft Virtual Server 2005, which is now obsolete.
A Little More Background

We are going to run the utility programs on a physical host machine running Windows Server 2012 R2 Standard x64 Edition SP2 (or later) in a Hyper-V role.

The guest OS installed on the .vhdx used in this example is Windows Server 2003 R2 Standard Edition SP2 (x86).  But this works for nearly all guest OS including Windows XP, Windows 10 x64 and Windows 2012 R2 x64 all the way up to Windows Server 2019.

This technique is known to work using .vhd and .vhdx images holding machines running Windows 2003 R2 OS and later.  If you are running Windows Server 2012 R2 in the virtual machine, it will not be necessary to run the DISKPART utility from the command line in the physical host, you can do all you need to do to accomplish the expansion by changing the settings alone.

Steps to Extend and Expand Disk Capacity of a Windows Server 2003 R2 C: Drive Disk (in .vhdx format)

  • Please insure you have a reliable backup copy of the virtual machine before starting this process or any other involving significant changes to the virtual guest machine.  We will be shutting down the virtual machine in order to avoid any physical resource allocation or other conflicts, as the operating system disk drive will be in use when it is mounted later in this process).

  • Start up Hyper-V Manager on the physical host.  Shut down the virtual machine to be expanded.

    Go into Settings for the virtual machine. Select Hard Drive and click on Edit.

  • Select Expand.

  • Enter the new size and click Next.

  • Click on Finish.

  • Get to command entry on the physical host Windows Server 2012 R2

    Start the DISKPART utility.


    Microsoft DiskPart version 10.0.14393.0

    Copyright (C) 1999-2013 Microsoft Corporation. On computer: YOURSERVERNAME


  • Double check to make sure the virtual machine is still off (shut down)

  • Run select vdisk, where

    D:\Hyper-V\Virtual Hard Disks\vwhv2003c.vhdx is the path and file of the virtual disk to be mounted

    DISKPART> select vdisk file="D:\Hyper-V\Virtual Hard Disks\vwhv2003c.vhdx"

    DiskPart successfully selected the virtual disk file.

  • Run the next 6 commands in order to mount and extend the virtual hard drive.

    DISKPART> list vdisk

      VDisk ###  Disk ###  State                 Type       File
      ---------  --------  --------------------  ---------  ----
    * VDisk 0    Disk ---  Added                 Unknown     D:\Hyper-V\Virtual Hard Disks\vwhv2003c.vhdx

    DISKPART> attach vdisk

      100 percent completed

    DiskPart successfully attached the virtual disk file.

    An additional disk drive will now show under My Computer
    (shows as F drive in this example)

    DISKPART> list vdisk

      VDisk ###  Disk ###  State                 Type       File
      ---------  --------  --------------------  ---------  ----
    * VDisk 0    Disk 1    Attached not open     Expandable  D:\Hyper-V\Virtual Hard Disks\vwhv2003c.vhdx

    DISKPART> list disk

      Disk ###  Status         Size     Free     Dyn  Gpt
      --------  -------------  -------  -------  ---  ---
      Disk 0    Online          952 GB      0 B
    * Disk 1    Online           44 GB  5120 MB

    DISKPART> list volume

      Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
      ----------  ---  -----------  -----  ----------  -------  ---------  --------
      Volume 0     E                       DVD-ROM         0 B  No Media
      Volume 1         System Rese  NTFS   Partition    350 MB  Healthy    System
      Volume 2     C                NTFS   Partition    124 GB  Healthy    Boot
      Volume 3     D                NTFS   Partition    827 GB  Healthy
      Volume 4     F                NTFS   Partition     38 GB  Healthy

    DISKPART> select volume 4 (in this example)
    Volume 4 is the selected volume.

    Double check that you have selected the correct volume.
    One way to do this is by checking the size of the volume.

    DISKPART> extend

    DiskPart successfully extended the volume.

    DISKPART> list volume

      Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
      ----------  ---  -----------  -----  ----------  -------  ---------  --------
      Volume 0     E                       DVD-ROM         0 B  No Media
      Volume 1         System Rese  NTFS   Partition    350 MB  Healthy    System
      Volume 2     C                NTFS   Partition    124 GB  Healthy    Boot
      Volume 3     D                NTFS   Partition    827 GB  Healthy
    * Volume 4     F                NTFS   Partition     43 GB  Healthy

    DISKPART> detach vdisk

    DiskPart successfully detached the virtual disk file.

    DISKPART> exit

    Leaving DiskPart...

    C:\Users\Administrator> exit

End of Steps to Expand Windows Server 2003 Disk Capacity
  • In most cases it will make sense to create a new backup copy before going live and into production mode.

    Start up the virtual machine.
    You have succeeded!

        go to the home page         Site Map     Switch to
Mobile View

You are at the web site of Tegratecs Development Corp.  Click here to go to the home page of this site...
Offering Innovation & Providing ROI
while minimizing Islands of Automation
Our contact information:
Tegratecs Development Corp.®
1320 Tower Road
Schaumburg, IL 60173
( please contact us or register or sign-in )
© 2012-2024