Virtual PC Guy's Blog

-- Ben Armstrong, Virtualization Program Manager

Talking about core virtualization at Microsoft (Hyper-V, Virtual PC and Virtual Server).

Welcome to MSDN Blogs Sign in | Join | Help

Quick Fixed VHD Creation Tool

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

Published Wednesday, March 25, 2009 11:07 AM by Virtual PC Guy
Filed under:

Comments

# re: Quick Fixed VHD Creation Tool

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.

Thursday, March 26, 2009 11:27 AM by Aitor Ibarra

# re: Quick Fixed VHD Creation Tool

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?

Thursday, March 26, 2009 1:07 PM by Hyper User

# re: Quick Fixed VHD Creation Tool

Awesome. This will be a massive timesaver.

Tuesday, April 07, 2009 6:54 PM by Gavin Raymen

# re: Quick Fixed VHD Creation Tool

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

"

Thursday, April 09, 2009 6:50 PM by Jim L

# re: Quick Fixed VHD Creation Tool

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?

Thursday, April 09, 2009 7:25 PM by Jim L

# re: Quick Fixed VHD Creation Tool

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?

Thursday, April 09, 2009 11:28 PM by Jim L

# re: Quick Fixed VHD Creation Tool

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 :(...

Friday, April 10, 2009 12:05 AM by Jim L

# re: Quick Fixed VHD Creation Tool

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?

Friday, April 10, 2009 12:08 AM by JIm L
New Comments to this post are disabled
 
Page view tracker