The cross-platform way to stream an OS image to a device
etcher-image-write by running:
$ npm install --save etcher-image-write
imageWrite.write(drive, image, options) ⇒
NOTICE: You might need to run this function as sudo/administrator to avoid permission issues.
We recommend passing file descriptors opened with
The returned EventEmitter instance emits the following events:
progress: A progress event that passes a state object of the form:
type: 'write' // possible values: 'write', 'check'.percentage: 905transferred: 949624length: 10485760remaining: 9536136eta: 10runtime: 0delta: 295396speed: 949624
error: An error event.
done: An event emitted with a boolean success value.
check option is useful to ensure the image was
successfully written to the device. This is checked by calculating and
comparing checksums from both the original image and the data written
to the device.
transform option is used to handle cases like decompression of
an image on the fly. The stream is piped through this transform stream
after the progress stream and before any writing and alignment.
This allows the progress to be accurately displayed even when the client doesn't know the final uncompressed size.
For example, to handle writing a compressed file, you pass the
compressed stream to
.write(), pass the compressed stream size,
and a transform stream to decompress the file.
Kind: static method of
Summary: Write a readable stream to a device
EventEmitter - emitter
||drive file descriptor|
||image readable stream|
||image stream size|
||enable write check|
||bmap file contents|
||bytes to zero out from the beginning (bmap only)|
var emitter = imageWrite;emitter;emitter;emitter;
The errors we emit can be identified by their
Consult this file for a list of defined errors.
If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.
To run the full test suite (Node & Electron), you'll need to have Electron installed
either globally or locally in the repository (
npm install [--global] electron).
Run the test suite by doing:
$ npm test
To run only the Node or Electron tests, respectively:
$ npm run test-node # OR$ npm run test-electron
- Issue Tracker: github.com/resin-io-modules/etcher-image-write/issues
- Source Code: github.com/resin-io-modules/etcher-image-write
Before submitting a PR, please make sure that you include tests, and that jshint runs without any warning:
$ npm run lint
etcher-image-write is free software, and may be redistributed under the terms specified in the license.