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

Increase Size and Capacity of a Virtual Hard Disk (.vhd)

the Essence

This technical article outlines the steps required for extending a virtual hard disk (.vhd) containing a Windows Server 2003 R2 installation.  You can also toggle between fixed and dynamic size formats with this technique.  You can even resize the C: drive containing the Windows 2003 R2 operating system and registry.

Here are the main components required:

  • VHD Resizer from VMtoolkit
  • vhdmount.exe utility program, included in Microsoft Virtual Server 2005 R2 SP1
  • DISKPART.exe utility program, included in Windows Server 2003

Why are we here?

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

  • You want to change a virtual hard disk to use dynamic sizing instead of fixed

  • 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).

  • through the use of this technique, you can toggle between fixed and dynamic sized disks.  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 copying the larger .vhd file sizes).  Using the base Virtual Server 2005 R2 product without the VHD Resizer, you are able only to change a dynamic sized disk to a fixed size disk.
A Little More Background

We are going to run the utility programs on a physical host machine running Windows Server 2003 R2 Standard x64 Edition SP2.  MS Virtual Server 2005 R2 SP1 and IIS are installed on the physical host.

The guest OS installed on the .vhd used in this example is Windows Server 2003 R2 Standard Edition SP2 (x86).

This technique is known to work using .vhd images created through Microsoft Virtual Server 2005 R2 SP1.  You may be able to use .vhd images from other virtualization platforms, but we have not tested them using this technique.




Steps to Extend and Expand Disk Capacity of a Windows Server 2003 Virtual Disk (in .vhd format)



  1. Please insure you have a reliable backup copy of the .vhd file before starting this process or any other involving significant changes to the virtual guest machine.
  2.   We'd also like to suggest that the virtual machine of our focus should be turned off, in order to avoid any physical resource allocation or other conflicts (as it will be in use when it is mounted later in this process).

  3. Download VHD Resizer from VMtoolkit (http://vmtoolkit.com)


  4. Install and run VHD Resizer.  This took about 15 minutes for a 16GB image.





  5. Set the current directory to C:\Program Files\Microsoft Virtual Server\Vhdmount or appropriate equivalent.


  6. Run vhdmount.exe, where

    /m

    Plugs in the specified .vhd file as a virtual disk device and mounts the volume. DriveLetter is optional. If drive letter is specified, the volumes are mounted starting at the specified drive letter. If drive letter is not specified, it is automatically assigned.

    Author's Note:  The optional drive letter specification did not work during our attempts to utilize it.

    Note:   The /m option uses Windows Virtual Disk Service (VDS) APIs to mount volumes on the disk. VDS APIs are only available in Windows Server 2003, Windows Server 2008, and Windows Vista. This means that /m does not mount the volumes when the host operating system is Windows XP. However, you can mount volumes manually in Windows XP by using Disk Manager.

    /f

    Mounts the virtual hard disk without an undo disk. All changes are made to the original virtual hard disk. By default, VHDMount mounts the virtual hard disk by creating a temporary undo disk, and changes are made to the undo disk.

    Courtesy of Microsoft TechNet, Mounting virtual hard disks at the command line

    and D:\vwin2003new.vhd is the path and file of the virtual disk to be mounted


    C:\Program Files\Microsoft Virtual Server\Vhdmount>vhdmount  /m  /f  D:\vwin2003new.vhd

    The Virtual Hard Disk is successfully plugged in as a virtual disk device and the volumes on the disk have been successfully mounted.

    An additional disk drive will now show under My Computer.


  7. Run DISKPART.exe and then 6 commands in order to extend the mounted virtual hard disk.

    DISKPART

    Microsoft DiskPart version 5.2.3790.3959
    Copyright (C) 1999-2001 Microsoft Corporation.
    On computer: YOURSERVERNAME


    DISKPART> list disk

      Disk ###  Status      Size      Free     Dyn  Gpt
      --------  ----------  --------  -------  ---  ---
      Disk 0    Online      279 GB        0 B
      Disk 1    Online       24 GB       8 GB


    DISKPART> list volume

      Volume ###  Ltr  Label        Fs     Type        Size     Status    Info
      ----------  ---  -----------  -----  ----------  -------  --------  --------
      Volume 0     C                NTFS   Partition     12 GB  Healthy   System
      Volume 1     D                NTFS   Partition    267 GB  Healthy
      Volume 2     F                NTFS   Partition     16 GB  Healthy
      Volume 3     E                       DVD-ROM         0 B  Healthy


    DISKPART> select volume=x
       where x equals the Volume # you wish to extend.

    Volume 2 is the selected volume.


    DISKPART> extend

    DiskPart successfully extended the volume.


    DISKPART> detail volume

      Disk ###  Status      Size     Free     Dyn  Gpt
      --------  ----------  -------  -------  ---  ---
    * Disk 1    Online        24 GB      0 B


    Readonly : No
    Hidden : No
    No Default Drive Letter: No
    Shadow Copy : No


    DISKPART> exit

    Leaving DiskPart...


  8. Unplug or un-mount the .vhd

    C:\Program Files\Microsoft Virtual Server\Vhdmount>vhdmount /u d:\vwin2003new.vhd

    Virtual disk device(s) successfully unplugged.


    C:\Program Files\Microsoft Virtual Server\Vhdmount


  9. Move the new .vdh file to the appropriate virtual machine directory and rename the files to utilize the new version in production.  Start up the virtual machine.  There will be a mild delay followed by a message requesting a server restart.



  10. Verify the new .vdh version.  Be sure to create a new backup copy before going live and into production mode.

References
Website of VMToolkit, Author of VHD Resizer

How to Expand a Microsoft Virtual Hard Disk File, at Computer Solutions blog

Additional options and alternative viewpoints for increasing the size of the .vhd, at groovyPost

Mounting virtual hard disks at the command line, at Microsoft Technet

How to extend a data volume in Windows Server 2003 and others, at Microsoft Support


        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
847-397-0088
800-739-FPSS
( please contact us or register or sign-in )
© 2012-2024