Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jhermsmeier/node-vhd
Microsoft's Virtual Hard Disk (VHD) Format
https://github.com/jhermsmeier/node-vhd
block-device disk disk-image hdd microsoft vhd vhd-format vhd-image
Last synced: about 2 months ago
JSON representation
Microsoft's Virtual Hard Disk (VHD) Format
- Host: GitHub
- URL: https://github.com/jhermsmeier/node-vhd
- Owner: jhermsmeier
- License: other
- Created: 2014-01-05T03:12:20.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2020-02-24T21:32:50.000Z (almost 5 years ago)
- Last Synced: 2024-10-11T07:34:07.201Z (2 months ago)
- Topics: block-device, disk, disk-image, hdd, microsoft, vhd, vhd-format, vhd-image
- Language: JavaScript
- Size: 708 KB
- Stars: 16
- Watchers: 5
- Forks: 7
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# VHD - Virtual Hard Disk
[![npm](https://img.shields.io/npm/v/vhd.svg?style=flat-square)](https://npmjs.com/package/vhd)
[![npm](https://img.shields.io/npm/l/vhd.svg?style=flat-square)](https://npmjs.com/package/vhd)
[![npm downloads](https://img.shields.io/npm/dm/vhd.svg?style=flat-square)](https://npmjs.com/package/vhd)
[![build status](https://img.shields.io/travis/jhermsmeier/node-vhd.svg?style=flat-square)](https://travis-ci.org/jhermsmeier/node-vhd)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](https://en.wikipedia.org/wiki/VHD_(file_format))
## Install via [npm](https://npmjs.org)
```sh
$ npm install --save vhd
```## Index
- [Types](#types)
- [Limitations](#limitations)
- [Usage](#usage)
- [TODO](#todo)
- [General](#general)
- [Dynamic Images](#dynamic-images)
- [Fixed Images](#fixed-images)## Types
- **Fixed** — The VHD image file is pre-allocated on the backing store for the maximum size requested.
- **Expandable** — The VHD image file uses only as much space on the backing store as needed to store the actual data the virtual disk currently contains. **Note**: The maximum size of a dynamic virtual disk is 2,040 GB.
- **Differencing** — A parent virtual disk is used as the basis of this type, with any subsequent writes written to the virtual disk as differences to the new differencing VHD image file, and the parent VHD image file is not modified. **Note**: The maximum size of a dynamic virtual disk is 2,040 GB.For more information, see [MSDN](http://msdn.microsoft.com/en-us/library/windows/desktop/dd323654.aspx)
## 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)```js
MAX_BAT_SIZE = ( tableEntries = ( diskSize / sectorSize )) * VHD.TABLE_ENTRY_SIZE
```## Usage
```javascript
var VHD = require( 'vhd' )
```#### Fixed size VHD
```javascript
var fixed = new VHD.Fixed( './path/to/image.vhd' )
``````javascript
fixed.open( function( error ) {
if( error ) {
// Obviously, something went wrong...
} else {
// Ready to read/write to/from image
}
})
``````javascript
fixed.read( offset, length, function( error, bytesRead, buffer ) {
// ...
})
``````javascript
fixed.write( buffer, offset, function( error, bytesWritten, buffer ) {
// ...
})
``````javascript
fixed.close( function( error ) {
// ...
})
```## TODO
### General
- [ ] Write tests
- [ ] Add integration tests (with node-disk etc.)
- [ ] Flesh out docs
- [ ] Generate API docs
- [ ] Complete VHD spec doc
- [ ] Add runnable examples
- [ ] Add PR & Issue templates (?)### Dynamic Images
- [ ] Impl BlockDevice API
- [ ] Impl partitions
- [ ] Impl cross-sector reads
- [ ] Impl writes### Fixed Images
- [ ] Impl BlockDevice API
- [ ] Impl partitions