Home

Awesome

VHD - Virtual Hard Disk

npm npm npm downloads build status

VHD (Virtual Hard Disk) is a file format which represents a virtual hard disk drive (HDD). It may contain what is found on a physical HDD, such as disk partitions and a file system, which in turn can contain files and folders. It is typically used as the hard disk of a virtual machine. The format was created by Connectix for Connectix Virtual PC product, which was later acquired by Microsoft in 2003, for what is now known as Microsoft Virtual PC. Since June 2005, Microsoft has made the VHD Image Format Specification available to third parties under the Microsoft Open Specification Promise.

From Wikipedia's VHD article

Install via npm

$ npm install --save vhd

Index

<!-- MarkdownTOC --> <!-- /MarkdownTOC -->

Types

For more information, see MSDN

Limitations

All virtual disk types have a minimum size of 3 MB.

The VHD format has a built-in limitation of just under 2 TiB (2040 GiB) for the size of any dynamic or differencing VHDs. This is due to a sector offset table that only allows for the maximum of a 32-bit quantity - Which fits our JavaScript environment perfectly, since we can't work with 64 bit integers natively.

Memory Requirements

For a maximum size dynamic or differencing VHD, the maximum Block Allocation Table size amounts to just under 4MB with the default sector size of 2MB (4096 512-byte blocks per sector)

MAX_BAT_SIZE = ( tableEntries = ( diskSize / sectorSize )) * VHD.TABLE_ENTRY_SIZE

Usage

var VHD = require( 'vhd' )

Fixed size VHD

var fixed = new VHD.Fixed( './path/to/image.vhd' )
fixed.open( function( error ) {
  if( error ) {
    // Obviously, something went wrong...
  } else {
    // Ready to read/write to/from image
  }
})
fixed.read( offset, length, function( error, bytesRead, buffer ) {
  // ...
})
fixed.write( buffer, offset, function( error, bytesWritten, buffer ) {
  // ...
})
fixed.close( function( error ) {
  // ...
})

TODO

General

Dynamic Images

Fixed Images