Quick Fixed VHD Creation Tool

Quick Fixed VHD Creation Tool

  • Comments 16

A while ago I talked about why it takes so long to create a virtual hard disk, and a lot of people came back and said that in controlled environments they were willing to take the security risks / implications involved in order to have quick creation of fixed size virtual hard disks.

In response to this we have made a tool available that does just this:

http://code.msdn.microsoft.com/vhdtool

This tool allows you to create fixed size virtual hard disks very rapidly.  You should be aware that the technique used means that it is possible to access data that was previously deleted off of the physical hard disk by running data recovery tools inside the virtual machine.  As such you should only use this tool when you can trust all users of the virtual machine.

Cheers,
Ben

Leave a Comment
  • Please add 2 and 3 and type the answer here:
  • Post
  • Ben - many, many thanks for this. Most of my fixed vhds are created on "virgin" disks - meaning there's no data on them, so need to over-write  empty space with zeroes. This will slash provisioning time without the compromise of using a dynamic vhd.

  • This is a great tool. Would this feature be available in a future version of Hyper V Manager? Say as an option with the necessary warning?

  • Awesome. This will be a massive timesaver.

  • Hi,

    I posted this on the vhdtool webpage:

    "I just tried this tool, using the command line above for creating a 10GB fixed VHD. On the host, I got a 10GB .vhd. I use a partitioning tool, Bootit NG (http://www.terabyteunlimited.com) which can boot from floppy and do things like resizing partitions. So, I pointed a VMC to the new VHD, and booted with a Bootit NG floppy image, which took me to Bootit NG. I had intended to use Bootit NG to resize a partition, but when I look at the VHD in Bootit NG "Partition Work", instead of a 10GB "HD0", I had an ~130GB "drive"! Is it because this tool doesn't zero out the data and so Bootit NG is getting confused about the partition sizes? Any ideas about why this might be?"

    I also posted about the problem on Terabyte Unlimited's support newsgroup, and the response I got was:

    "BING just uses what the BIOS reports."

    so, apparently, with a VHD created using vhdtool, the VPC guest's BIOS is reporting, in my case, 130GB.

    Any idea why that might be and how to work around the problem?

    Thanks,

    Jim

    "

  • Hi,

    I just tried it again.  I used this command to create the VHD:

    P:\foo>VhdTool.exe /create "p:\foo\foo.vhd" 10737418240

           Status: Creating new fixed format VHD with name "p:\foo\foo.vhd"

           Status: Attempting to create file "p:\foo\foo.vhd"

           Status: Created file "p:\foo\foo.vhd"

           Status: Set the file length

           Status: Set the valid data length

           Status: VHD footer generated.

           Status: VHD footer appended.

           Status: VHD header area cleared.

           Status: Complete

    P:\foo>dir

    Volume in drive P is WD120GB

    Volume Serial Number is EC15-9FC3

    Directory of P:\foo

    04/09/2009  06:52 PM    <DIR>          .

    04/09/2009  06:52 PM    <DIR>          ..

    04/09/2009  06:52 PM    10,737,418,752 foo.vhd

    So, the foo.vhd is 10GB on the physical drive.

    When I boot into the BING from floppy, BING shows HD0 with an empty area of 130552 MB of free space.

    If I go to the VPC guest's BIOS at boot, it says:

    Device    : Hard Disk

    Vendor    : Virtual HD

    Size      : 136.9GB

    LBA Mode  : Supported

    Block Mode: 128Sectors

    PIO Mode  : 4

    Async DMA : MultiWord DMA-2

    So, it definitely looks like the guest's BIOS thinks that it's a 130GB drive.

    Any ideas how to fix this problem?

  • Hi,

    I created a smaller VHD so that I could see it in a hex editor:

    P:\foo>VhdTool.exe /create "p:\foo\foo.vhd" 13631488

           Status: Creating new fixed format VHD with name "p:\foo\foo.vhd"

           Status: Attempting to create file "p:\foo\foo.vhd"

           Status: Created file "p:\foo\foo.vhd"

           Status: Set the file length

           Status: Set the valid data length

           Status: VHD footer generated.

           Status: VHD footer appended.

           Status: VHD header area cleared.

           Status: Complete

    and then I used VPC2007's VHD wizard to create the same size VHD, foo1.vhd.

    Looking a foo.vhd vs. foo1.vhd, it looks like the "Disk Geometry" in the footer is different:

    foo.vhd (created by vhdtool.exe):

    0x34D3103F

    foo1.vhd (created by VPC2007 wizard):

    0x01870411

    Why is the "Disk Geometry" in the footer in the VHD created by vhdtool.exe different?

  • Hi,

    BTW, I just tried another test, creating a 5GB+ VHD, then installed Win2K.  Disk Management (in Computer Management) sees Disk 0 as a 127.49GB drive!!

    So, it's not just Bootit NG that thinks that the vhdtool-created VHD is a 130GB drive...  Win2K Disk Management also sees a 130GB drive :(...

  • Hi,

    I'm wondering, has anyone actually used vhdtool.exe to create a VHD, and then installed, say, Win2K on the VHD, and had Win2K report the "correct" disk size?

  • It sounds like there are a lot of people that are misunderstanding this tool. Given that it is unanswered and first hit on bing searches I'd like clarify the behavior.

    Vhdtool.exe works by extending the end of file pointer of vhd. This gives it the great speed as its an index update but leaves the security vulnerability that the physical bytes are not zeroed out. Due to being a security risk it will never be shipped in a future release.

    After AttachVirtualDisk() has occured the vhd to be treated as a larger Win32_DiskDrive. Inside of that DiskDrive are many "partitions" (Win32_Volume) which will all contain the existing values. Until the volumes have been expanded there is no way to utilize the additional space. This is why the values do not increase initially inside of the OS.

    I dont know of these random tools people are using as everything is freely built into Windows. Right click on My Computer->Manage and navigate to Disk Management. Select the volume and request Extend Volume to solve those problems.

  • When I use this one some disks I get a hung server after the point where the tool tells me that VHD footer generated.  It just hangs and the only way out is to reboot the server.  What is going wrong?  It worked on other servers, they are all manager with VMM 2012, have disks on cluster shared volumes.

  • Any chance of getting this tool updated to created VHDX files?

  • Please update this tool to create VHDX format files. We've had performance issues with dynamic VHDXs and I need a tool to create a multi TB, thick, lazy zeroed VHDX. This should be an option in Hyper-V out of the box, I need to flexibility to decide whether a security risk exists or not.

  • Hi !

    When this tool will support VHDX format? Although the dynamic vhdx has excellent performance, some applications only endorse fixed vhd or vhdx disks.

  • Ben, the link you provided does not work - MSDN Archive Gallery has been retired and vhdtool is no longer available. I tried to search if the tool was mirrored somewhere but without success. Do you know if there are any chances the tool will be available again?

  • Does anyone have a copy of the utility they can upload somewhere? Microsoft is no longer hosting the file.

Page 1 of 2 (16 items) 12