Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write image to usb with dd #435

Open
SBecker71 opened this issue Jul 30, 2024 · 4 comments
Open

Write image to usb with dd #435

SBecker71 opened this issue Jul 30, 2024 · 4 comments

Comments

@SBecker71
Copy link

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
Copy link
Owner

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
Copy link

ale5000-git commented Jul 31, 2024

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

@SBecker71
Copy link
Author

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 added a commit that referenced this issue Aug 2, 2024
A common use of 'dd' is to copy boot images to removable media.
This didn't work on Windows because opening a physical drive
failed with the default flags used by 'dd'.

If the output file is a physical drive remove incompatible flags.

Writing to a physical drive requires elevated privileges and the
drive must be offline.

Adds 80 bytes.

(GitHub issue #435)
@rmyorston
Copy link
Owner

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

  • The commands need to be run as Administrator.
  • The disk needs to be offline. This can be done using the GUI tool diskmgmt.msc or the command line tool diskpart:
~ # diskpart

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 are available (PRE-5444 or above).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants