Search Wiki:
The Downloads page contains the downloadable files (binaries, readme document, and source code project).

Latest News


  • The next release of VHD tool is now available.
  • I've added a "repair" function which is designed to undo an expand operation on a base VHD when differencing VHDs are present. This is useful in cases where an admin accidentally expands a base VHD when Hyper-V snapshots are present.
  • To ensure data integrity in the case of an error, please make a backup copy of your VHDs before altering them with this tool.

Introduction

VHD tool is an unmanaged code command-line tool which provides useful VHD manipulation functions including instant creation of large fixed-size VHDs. The source code is included.

Requirements

  • A computer running one of the following Windows operating systems:
    • Server: Windows Server 2003 or above
    • Client: Windows XP or above
  • NTFS file system

Usage

VhdTool.exe /create <FileName> <Size> [/quiet]
VhdTool.exe /convert <FileName> [/quiet]
VhdTool.exe /extend <FileName> <NewSize> [/quiet]
VhdTool.exe /repair <BaseVhdFileName> <FirstSnapshotAVhdFileName> [/quiet]
 
Create: Creates a new fixed format VHD of size <Size>.
        WARNING - this function is admin only and bypasses
        file system security.  The resulting VHD file will
        contain data which currently exists on the physical disk.
 
Convert: Converts an existing RAW disk image file to a fixed-format VHD.
         The existing file length, rounded up, will contain block data
         A VHD footer is appended to the current end of file.
 
Extend: Extends an existing fixed format VHD to a larger size <Size>.
         WARNING - this function is admin only and bypasses
         file system security.  The resulting VHD file will
         contain data which currently exists on the physical disk.
 
Repair: Repairs a broken Hyper-V snapshot chain where an administrator
        has expanded the size of the root VHD.  The base VHD will be
        returned to its original size. THIS MAY CAUSE DATA LOSS if the
        contents of the base VHD were changed after expansion.


Known Issues

There are currently no known issues.

Frequently Asked Questions

How do I file a bug?
Click on the "Issue Tracker" tab and choose to "Create New Item".

Examples

Create a new 10 GB fixed VHD in the current directory.
VhdTool.exe /create "c:\Program Files\MyApp\foo.vhd" 10737418240

Convert an existing flat image file into a VHD & do not output status to the command line.
VhdTool.exe /convert bar.img /quiet

Extend an existing fixed format VHD to a larger size.
VhdTool.exe /extend foo.vhd 21474836480

Repair a Hyper-V snapshot chain broken by expanding the base VHD.
VhdTool.exe /repair base.vhd base_EF2F9402-E85B-402F-A979-631CB287C2C4.avhd

Links

VHD Specification

Last edited Oct 22 2009 at 11:34 PM  by ChrisEck, version 22
Comments
ru wrote  Mar 26 2009 at 4:49 AM  
Chris: feature request: could you set size default in GB? so we can type in 10 and it would default to 10GB?

RogerC wrote  Mar 28 2009 at 4:18 PM  
Great Tool this has saved me a lot of time when creating large VHD files. I second the above feature request and also one question. When you run the tool can you specify a directory to drop this in or do you have to run the tool from the location that you want the file to be in if you have to be in the directory where you want it I would like to add a second feature request of the ability to define a location to create the file in? Thanks

Roger Crawford

ChrisEck wrote  Apr 2 2009 at 7:09 PM  
RogerC - Yes, you can specify a full path to the file. I'll add an example showcasing this.

ChrisEck wrote  Apr 2 2009 at 7:11 PM  
ru - No, that would reduce the flexibility of the tool. I'll let you wrap this in your own script if you want to accomplish that.

plynch wrote  Apr 6 2009 at 1:38 PM  
I just wanted to say how awesome this tool is. I just created a test 4GB VHD and it did it so quick I thought it had failed - it hadn't, it had created a 4GB VHD in the blink of an eye - literally. Awesome !

davewilk wrote  Apr 11 2009 at 10:13 AM  
Does this work for creating SCSI disk for Virtual Server?

ChrisEck wrote  Apr 20 2009 at 4:22 PM  
Dave, this tool creates valid VHD 1.1 spec compliant VHDs, so any application which uses VHDs should be able to use these.

Dafydd wrote  Oct 20 2009 at 6:14 PM  
Flamming genius this has just rescued a CRM App Server installation (which is still in testing so no DR or backup) after a young collegue resized the base vhd. THANK YOU

ChrisEck wrote  Oct 22 2009 at 11:36 PM  
I've removed the bug reports from the comments section. Please file future bug reports in the "Issue Tracker" tab.

Kbubp wrote  Oct 28 2009 at 6:15 PM  
It would be nice in the next release to not have to use kilobits. Instead, do what VMWare's vhd tool does and use G and M for gigabyte and megabye. e.g. vhdtool /create drive.vhd 20G or vhdtool /create drive.vhd 256M

Morpheus666 wrote  Nov 20 2009 at 7:19 AM  
This is fast! Why are they so much smaller than a 'regularly' created vhd? I set a size of 210GB and when I mount it, it is 195GB!
I like the speed, but not the loss of space.

seanofarrell wrote  Nov 25 2009 at 2:37 AM  
Any chance you could contact me. Have a quick query. Trying to merge a avhd file with broken differencing chain sean at netforce.ie

ASidles wrote  Dec 11 2009 at 5:43 AM  
This tool is the bomb! Repaired an expanded echange server vhd within 15 minutes on first try! Not an email was lost. Awesome job Chris!

ChrisEck wrote  Dec 11 2009 at 7:27 PM  
seanofarrell - you should be able to contact me via the contact link available through the "People" tab.

ChrisEck wrote  Dec 11 2009 at 7:27 PM  
ASidles - glad to hear it was useful.

ChrisEck wrote  Dec 11 2009 at 7:28 PM  
Morpheus666 - the VHD's virtual size is correct, but you're probably losing some space either because of the bus type you've mounted on or the file system inside the VHD. Please verify you see the full amount expected if you try a smaller value (sub 100 GB).

Junroot wrote  Jan 6 at 6:10 PM  
Hi ChrisEck, your tool is very powerfull!
whenever, when does this tool support windows 2000 pro\server?
Thank you!

ChrisEck wrote  Jan 22 at 4:57 AM  
Junroot - this tool will never support running on Windows 2000. Not only is Windows 2000 beyond end-of-life, but the platform support required for the tool did not exist prior to the OS releases listed in the requirements. You should consider upgrading to an OS made this millennium ;)

Updating...
Page view tracker