Saturday, December 12, 2009

How to Expand a Microsoft Virtual Hard Disk File

Have you ever created a virtual machine hard disk file, installed the operating system and configured everything the way you want only to find out there is not enough room to install the applications you need on the virtual computer because of lack of space? Now there is an easy way to grow to the size of the virtual hard disk (.VHD) file and extend the operating system or other disk partitions without a complete system rebuild. Read on to find out how.

Instructions

Things You'll Need:

  • VMTOOLKIT.COM VHDRESIZER
  • Microsoft .NET Framework 2.0 installed on your computer
  • Microsoft Virtual Server 2005 R2 SP1
  • Optional (
  • Windows PE or BartPE CD or .ISO image)
  1. Step 1

    First, obtain VHD Resizer from VMTOOLKIT.COM. Download the .zip compressed file, extract the .msi file to a temporary location ie: C:\temp and install it. Follow the default installation prompts. Click 'Close' to complete the installation.

  2. Step 2

    Run VHDResize.exe, browse and select the .VHD file from your Virtual Machine directory that you wish to expand.

  3. Step 3

    Select the location you wish to store the new .VHD file in and enter the name of the new .VHD file you are going to create.

  4. Step 4

    Determine the type (fixed or dynamic) of .VHD file you are expanding/creating and enter the size of the new .VHD file.

  5. Step 5

    Click Expand and wait for process to complete.

  6. Step 6

    Click Exit to close the program.

  7. Step 7

    After the virtual drive has been expanded you will need to expand the partition(s) within the virtual drive. To do this will require DISKPART.EXE from Microsoft.

  8. Step 8

    There are three software packages you can use to mount the new virtual drive file to expand the partition. BartPE, Windows PE or Microsoft Virtual Server 2005 R2 SP1. BartPE and Microsoft Virtual Server are free while Windows PE requires special licensing from Microsoft. Choose whichever software package is best suited to your needs.

  9. Step 9

    To expand the virtual drive using BartPE or Windows PE see my article: How to extend the size of VMware disk file on VMware Server or Workstation. For this article I will use Microsoft Virtual Server. Download Microsoft Virtual Server 2005 R2 SP1 from Microsoft, http://www.microsoft.com/virtualserver.

  10. Step 10

    Install Virtual Server using a custom install, selecting only VHD Mount or from a RUN box or command prompt type: msiexec /i “Virtual Server 2005 Install.msi” /qn ADDLOCAL=VHDMount and press 'Enter'.

  11. Step 11

    Open a command prompt window and navigate to C:\Program Files\Microsoft Virtual Server\VHDMount. Mount the .VHD file using the following commands:

    vhdmount /m /f (path and name of .vhd file)

  12. Step 12

    Run diskpart to expand disk.

    c:\>DISKPART --> press Enter
    DISKPART> type 'list disk' --> press Enter
    DISKPART> type 'list volume' --> press Enter
    DISKPART> type 'select volume=#' (where # is the number of the volume you wish to extend) --> press Enter
    DISKPART> type 'extend' --> press Enter to extend the disk file.
    DISKPART> type 'detail volume' --> press Enter to verify the size of the new partition.
    DISKPART> type 'exit' --> press Enter to exit diskpart.

  13. Step 13

    To dismount the .VHD file, type vhdmount /u (path and name of file)

  14. Step 14

    Attach new .VHD file to virtual machine

No comments:

Post a Comment