rmyorston / busybox-w32

WIN32 native port of BusyBox.
https://frippery.org/busybox
Other
696 stars 126 forks source link

Write image to usb with dd #435

Open SBecker71 opened 4 months ago

SBecker71 commented 4 months ago

I can't get dd to write a image file (ex. Dos6.22.img) to a usb stick (f:) I am using Win11. Any ideas?

I tried:

dd if=Dos6.22.img of=f:\ dd: can't open 'f:\': No such file or directory

or

dd if=Dos6.22.img of=\.\f: dd: can't open '\.\f:': Permission denied

dd if=Dos6.22.img of=f: dd: can't open 'f:': Is a directory

Regards

rmyorston commented 4 months ago

I think it might be necessary to write to the physical rather than logical drive.

That would be dd if=Dos6.22.img of='\\.\PhysicalDriveN' where N is the disk number.

However, writing to either sort of device on Windows seems to require rather different settings than dd in BusyBox uses. And when it doesn't work the error messages aren't very helpful.

I'll continue to tinker with it, but don't expect a rapid fix. Or any fix at all.

ale5000-git commented 4 months ago

@rmyorston Is it possible to also add an applet that resolve logical drive to phisical drive? Like this: D: => \\.\PhysicalDriveN

SBecker71 commented 4 months ago

I tried the suggestion but:

dd if=Dos6.22.img of=\.\PHYSICALDRIVE2 dd: can't open '\.\PHYSICALDRIVE2': Invalid argument

So if i understood you right i have to wait if there (maybe) will be a solution.

Thank you for your help.

P.S.: dd for windows from http://www.chrysocome.net/dd works but i hoped i could use busybox because it is better supported

rmyorston commented 3 months ago

I've made a minimal fix to dd to allow it to write to physical drives (not partitions or volumes). There are some limitations:

Microsoft DiskPart version 6.3.9600

Copyright (C) 1999-2013 Microsoft Corporation. On computer: WIN81

DISKPART> list disk

Disk ### Status Size Free Dyn Gpt


Disk 0 Online 25 GB 0 B Disk 1 Online 10 MB 0 B

DISKPART> select disk 1

Disk 1 is now the selected disk.

DISKPART> offline disk

DiskPart successfully offlined the selected disk.

DISKPART> exit

Leaving DiskPart... ~ #

The `dd` command is then something like:

~ # dd if=144m/x86BOOT.img of='\.\PhysicalDrive1' bs=64k 22+1 records in 22+1 records out ~ #


The default block size is 512 bytes, which is far too small. I used `bs=64k` above for a floppy. I generally use `bs=1M` for ISO images.

Note, the path for the physical drive starts with _two_ backslashes.

[Prerelease binaries](https://frippery.org/files/busybox/prerelease) are available (PRE-5444 or above).