I look forward to writing directly on a raw block device.
I can successfully do this with dd for windows :
> dd.exe if=myData.dat of=\\.\PhysicalDrive1
However, I cannot do this with NodeJS. I use node-blockdevice as follows:
var device = new BlockDevice({ path: '\\\\.\\PhysicalDrive1', mode: 'w+', size: 512 }); device.write(0, myBuffer, callback);
device.write correctly returns the number of bytes written, but it doesn’t actually write anything to the device.
Please note that the exact code works successfully on Mac OS X (of course, substituting \\\\.\\PhysicalDrive1 with /dev/diskN ): it records my data and I can view it without any problems in Windows 8 .
What am I doing wrong?
I also tried:
- Do not avoid backslashes (
\\.\PhysicalDrive1 ), but this results in an EINV error. - Using a logical name:
\\\\.\\E: - Detach a volume using
mountvol X: /D before attempting to read / write.
I can correctly confirm the identifier of the device with which I want to write with:
wmic diskdrive list brief
I also tried setting mode to rs+ . The read operation seemed to work, but the stored data contained the following data related to the failure:
X MSDOS5.0 ? : )? xNO NAME FAT32 3ɎѼ { ٽ| V@ N V@ A U r U u t F - V@ s f @f ? Af f f F ~u9 ~*w3f Ff , } | t< t } } ߘ f` ~ fjfPSfh B V@ fXfXfXfX 3f;F r *f3 f Nf f f v ֊ V@ ̸ fa t f@Iu BOOTMGR Disk error Press any key to restart U %
EDIT: The github problem thread describing more things I tried: https://github.com/jhermsmeier/node-blockdevice/issues/1 .
EDIT: All of the approaches mentioned have been tested with administrator privileges.
EDIT: I am using device.close(callback) , but omitted in the example for simplicity.