/vhdtool

Manipulate VHD (Virtual Hard Disk) images the open-source way.

Primary LanguageC

VHDtool
==========

A tool to examine and manipulate VHD images. Initially
meant as a way to test dynamic VHD support in my
Linux kernel loop VHD parser support. Images mount
in Win7.

Why would you use this instead of qemu-img? VHDtool
lets you tweak more parameters and create funky
VHDs (and will support differencing disks soon too!).

One more reason is that qemu-img actually produces
corrupt images that don't fit the VHD spec. Unsure
if they event mount on Win7.

Stay tuned.

Building
========

Builds on recent Linux (i.e. not RHEL5, *sigh*), and
needs libuuid (you probably have it, but look for
libuuid-devel or some similar package).

To build:

$ make

Examples
========

$ ./vhdtool 
./vhdtool [-s size] [-b block_size] [-c] [-t type] create|convert ...

$ ./vhdtool create
./vhdtool -s size [-b block_size] [-c] [-t type] create vhd-file-name
command 'create' failed

$ ./vhdtool convert
./vhdtool [-b block_size] [-c] [-t type] convert source-file-name dest-file-name
command 'convert' failed

Generate a 512-byte fixed VHD:

$ vhdtool -s 512 create test.vhd

Generate a 50 sector fixed VHD:

$ vhdtool -s 512s create test.vhd

Generate a 12mb dynamic VHD:

$ vhdtool -s 12m -t dyn create test.vhd

Generate a 12mb dynamic VHD with non-default (2mb) block size:

$ vhdtool -s 12m -b 4m create test.vhd

Convert a raw image to a VHD

$ vhdtool convert test.raw test.vhd

Valid size modifiers are:
b/B/*nothing* -> bytes
k/K           -> kilobytes
m/M           -> megabytes
g/G           -> gigabytes
t/T           -> terabytes
s/S           -> sectors

Special Considerations
======================

You need to pass the '-c' option if you are creating images < 127GiB
in size and the following apply to you:

1) You are converting a RAW disk imag and will be using it with the
   emulated IDE controller in Hyper-V.

2) You are creating a new VHD and are expecting to use it both with
   the emulated IDE controller and the virtual SCSI adapter in
   Hyper-V.

The '-c' option, will ensure that the disk size implied by C/H/S
calculations will never be less than the desired image size, with
the side effect of making the image a little larger.

Contact Info
============

Andrei Warkentin (andrey.warkentin@gmail.com, andreiw@vmware.com, andreiw@msalumni.com)