73

I need to read and write various flash card images. The way i always did this in linux was with dd, and that did the trick. What is a good windows equivalent?

Simply put, i need to be able to read an entire card into a file and vice versa. I tried WinDD, but that seems to operate on partitions rather than entire devices, but i need to be able to dump the entire disk/card and its partition table regardless of its content.

Using Windows 7 64bit, with the card reader on a USB3 port.

15 Answers 15

21

Rufus works as expected. Choose 'DD Image' for 'Create bootable disk using'.

The source is published on GitHub: https://github.com/pbatard/rufus.

balenaEtcher is another Windows compatible tool for writing writing images to USB drives. It's also fast, and is easier to use than Rufus.

My experience: Win32DiskImager did not detect u-SD through a USB-3 reader; dd for Windows, MinGW compiled dd, Unix Utils dd, and Linux dd VIA VirtualBox VM USB3 pass-through were all unacceptably slow; I have yet to find a Windows command line equivalent that can beat the 50MB/s write speeds I'm seeing with Rufus.

6
  • My vote for Rufus as well. None of the other proposed answers worked for me on Windows 10 Pro v1703. Okay... lets be honest... I didn't try the Python solution. Jul 21, 2017 at 19:42
  • 6
    It is really good for preloading images on USB sticks, but it does not do half of what dd can do, so it's not really "equivalent"
    – Rolf
    Mar 27, 2018 at 21:29
  • 6
    This is not valid as it only allows to write images on disks, not to read those disks.
    – Xerz
    Apr 14, 2018 at 18:15
  • 2
    Rufus produced a disk with different checksum from the image, for me.
    – fuzzyTew
    Dec 24, 2018 at 23:53
  • 1
    It's rare to see a useful application today that is only 1mb in size. What a great tool! Mar 5, 2019 at 20:55
32

Just use dd for WIndows ... it works perfectly even though it is quite an old project.

5
  • 2
    Seems to have an issue under windows 10. Anyone having issues with .6 beta 3? Nov 12, 2015 at 19:14
  • @TravisWhidden what kind of issues? I've experienced some "unable to write" errors, but unsure if that's the same problem. Apr 8, 2016 at 10:34
  • It doesn't work for me on my Win7 machine
    – Aaron
    Jan 19, 2017 at 16:51
  • This seems to work, but it seems slooooow ...
    – user230910
    Oct 16, 2018 at 22:29
  • Thank you, worked great for me.
    – Jesbus
    Aug 30, 2019 at 13:06
26

Try Win32DiskImager , it can write images to disks.

11
  • 5
    @AnthonyLozano I downloaded win32diskimager from sourceforge, it doesn't have any malware and it's widely used and even recommended for things like the Raspberry Pi to write disk images to. There is a fork on github but you have to compile it yourself github.com/bizplay/win32-disk-imager
    – user345419
    Oct 18, 2016 at 0:12
  • 2
    I have started using Chocolatey for all of my utilities. Think apt-get for Windows using NuGet's framework. There is a win32diskimager package on there that installs with no issues. Portable one, as well. chocolatey.org
    – Mike Loux
    May 23, 2017 at 18:24
  • 10
    This doesn't work for devices without partition letters assigned to them, thus it's useless for devices with unrecognized partitions or no partitions at all. Not an equivalent to dd.
    – Xerz
    Apr 14, 2018 at 18:14
  • 2
    It doesnt make a dd compatible image file, in fact it tries to understand the disk layout and produces a zip file with each partition it recognises in a separate file. And in my case it had issues restoring the files back to partitions again
    – user230910
    Oct 16, 2018 at 22:28
  • 1
    @MikeLoux Chocolatey installs win32diskimager from SF: Downloading win32diskimager.install from 'https://sourceforge.net/projects/win32diskimager/files/Archive/win32diskimager-1.0.0-install.exe' Apr 15, 2020 at 22:04
15

First I also tried Win32DiskImager, which I thought is doing only partition copy based on its display (no, it can backup an entire SD card), so I continued searching.

My current favourite is HDDRawCopy. It copies to/from file an entire disk image, but not partitions separately. It creates dd compatible or compressed images on the fly - not as efficient as 7zip (does not reach ZIP performance even) but you don't need to touch the image again.

3
  • 2
    HDD Raw Copy was able to detect a blank SCSI drive that "dd for windows" could not. It allowed me to duplicate an HFS disk from Windows! Thanks!
    – HackSlash
    Feb 16, 2018 at 23:53
  • 4
    Note that for some reason HDD RAW COPY has a limit of 50MB/s
    – Gizmo
    Jul 6, 2018 at 11:11
  • HDD Raw Copy helped me to create an image of an USB stick with "cyclic redundancy check" errors. Allowing me to recover a lot of data despite the total loss of the USB key.
    – Destroyica
    Nov 12, 2021 at 16:05
15

surprised nobody mentioned GNU core utils for Windows, I've been using them for years. they're 32-bit binaries but apparently, except for less, they still work under Windows 7 64-bits.

example usage:

C:\Windows\Temp>dd if="\\.\s:" of=sdrive.dat bs=4096
25599+0 records in
25599+0 records out
104853504 bytes (105 MB) copied, 30.3147 seconds, -56145186608800624000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000 MB/s

C:\Windows\Temp>dd if="\\.\physicaldrive0" of=mbr.dat bs=512 count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.0210012 seconds, -891479495977528 kB/s

the reported times are a bit odd but otherwise it seems to work well.

7
  • 2
    Does it copy correctly content over 4 gibibytes? Last time I checked (long ago) it was compiled against Microsoft's runtime where off_t is a long, hence offsets are limited to 31 or 32 bits... which is a big deception when using dd.
    – AntoineL
    Sep 15, 2018 at 14:40
  • I never tried, sorry. Sep 18, 2018 at 4:38
  • Git for Windows comes (at time of writing) with dd version 8.30, compiled in 2018. It seems to work fine with /dev/sdX names, at least from Git Bash running as Administrator. It probably lost any 32-bit limitations some time ago.
    – mwfearnley
    Oct 1, 2019 at 12:29
  • I went this way to WRITE an image file to a SD-Card and it seemed to work. But if the card already had a drive letter before, it seems windows doesn't notice the modified data and you get corrupted data as soon as you try to write on that disk. Any solution for that? How to do the flashing with un- and remount correctly?
    – maf-soft
    Dec 8, 2020 at 11:20
  • 1
    -56145186608800624000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000 MB/s? Interger overflow?
    – raspiduino
    Jun 6, 2022 at 16:03
10

For a true equivalent of dd on Windows, don't look for half-baked alternatives — just install the real GNU dd. The best ways to do this are probably Cygwin and Msys2, pretty complete distributions of GNU and other FOSS tools. Think of it as installing "Linux" on top of Windows, without any emulation layers or a limited black box like the Windows Subsystem for Linux. It's as native as it gets.

In order to use either one of them, you'll need to:

  1. Install a basic environment. Do so as instructed either for Cygwin or for Msys2, just leave the defaults if you only need dd — but you can also have some fun and get a hint on what it has to offer.
  2. Open the respective terminal as administrator, then check which device/partition you want to work on with cat /proc/partitions.
  3. Use dd as you would on any Linux.
3
  • you can even use cygwin from the DOS command prompt... (i use all the time for cat/grep/tail/... ) and even in the DOS/Windows console "ls -la /proc" works fine... one of my favorits...
    – ZEE
    Apr 17, 2018 at 21:23
  • 1
    cygwin has ddrescue too
    – barlop
    Nov 8, 2020 at 0:33
  • Thank you. I was stuck at where I would normally do lsblk on linux to figure out the device name.
    – Rolf
    Sep 22 at 21:41
8

I was just trying to verify a drive was wiped, so all I cared about was reading, but this python script could be modified to do anything like this if you don't trust those executables like I didn't. Open Windows Partition Manager to get what the drive number of drive you care about is, and just change that 2 to that number. You can then write that out, or if you did wb instead of rb you could write. Good luck

import sys

f = open('\\\\.\\PhysicalDrive2','rb')
a = f.read(1)
i = 1

kb = 1024
mb = kb*1024

while a == b'\x00':
    i+=1
    if i % mb == 0:
        sys.stdout.write('\r{} MB scanned'.format(i/mb))
    a = f.read(1)

print('done')
3
  • 5
    Just for the record, I think it would be many times faster to do more than one byte at a time. And there is no error condition, the script relies on non-null bytes occurring early on and you catching that it printed "done" early on.
    – Luc
    Apr 29, 2017 at 18:44
  • 2
    How do you know what drive to target?
    – HackSlash
    Feb 16, 2018 at 23:56
  • Python is the wrong tool a tight loop like that. You'd be better off creating a 256k buffer of all zeroes and comparing it to 256k pulled from the disk in one go. Plus having some exception handling. Mar 5, 2019 at 21:04
4

BusyBox for Windows(32bit and 64bit versions) contains dd with support of /dev/zero and /dev/urandom

Examples:

C:\>busybox dd if=\\.\physicaldrive0 of=mbr.bin bs=512 count=1
1+0 records in
1+0 records out

C:\>busybox dd if=\\.\G: of=disk.img
2006465+0 records in
2006465+0 records out

Help: busybox dd --help

3

wow all those responses and DISM has been around for how long? pretty sure it was built into windows 7 from the get go.

DISM /capture-image /image-file:d:\backup.wim /capturedir:c:\ /name:simpleback

there are alot of settings you can tweak. after you capture - deploy to new storage media using the dism tools also.

4
  • 1
  • Doesn't work: The /image-file option is not recognized in this context.. Should be /imagefile
    – yahol
    Aug 27, 2019 at 11:21
  • 3
    It seems that this command uses special image files and not just a raw copy of the data.
    – maf-soft
    Dec 8, 2020 at 11:23
  • 2
    -1 because DISM is by no means a dd alternative. dd is just copying bytes from source to target without processing them. DISM is archiving a NTFS filesystem to a proprietary format.
    – gronostaj
    Jan 14, 2021 at 9:45
2

After trying some of the tools recommended here, I ended up using balena Etcher on Windows 10. (Rufus gave me a result with an incorrect checksum. HDDRawCopy gave me a write error.)

2

If you have git installed for windows (tortoiseGit), it ships with Git Bash.

Git bash has dd built-in, and you can access phyical drivers directly using "physicalDrive".

An example that reads the full card contents into a file (You need admin permissions and need to know the physicalDrive index -- assuming 3 there):

dd if='\\.\PhysicalDrive3' of=/c/Temp/file.bin

An example that reads a bin file, and writes it after 1000bytes into phyicaldrive33.

dd if=/c/Temp/someDummyFile.bin bs=1 seek=1000 of='\\.\PhysicalDrive33' conv=notrunc,nocreat

Another useful tool is HxD. It allows you to graphically open physical drivers too and inspect/edit them on the fly.

1
  • You can also just use cat /dev/sdN > raw_image.img on git bash. No PhysicalDrive names necessarily needed.
    – Wyatt Ward
    Oct 26 at 16:01
1

rawcopy from http://www.ltr-data.se/opencode.html/. rawcopy -h shows manual.

If you need /dev/zero and /dev/random, there is "Zero and Random device driver" from the same site.

1

Git for Windows has all Linux coreutils along with the dd which worked fine for me on the recent Windows 10 versions:

http://git-scm.com/download/win

It has portable zip variant also, so you can just unpack it into your WinPE bootable USB stick and have all the power of Unix/Linux tools on it. (I created my WinPE stick with the free version of Paragon Backup & Recovery. It has cmd shell from which you can start as many git-bash windows as you wish.)

1

Available for download is dd; is a common program with the primary purpose of low-level copying of raw data. Once installed, open the command prompt and type (substitute the correct path):

Updated file at: http://www.chrysocome.net/downloads/dd-0.5.zip

Usage: http://www.chrysocome.net/dd

dd.exe if=/path/to/the/downloaded/iso of=/path/to/the/USB/device
1
  • 2
    This link was already posted by Eugen Rieck 6 years ago and is one of the highest upvoted answers. If you want to improve on their answer, use the Edit button.
    – gronostaj
    Jan 14, 2021 at 9:47
1

Just installed Git Bash on Windows 10 (download it here) and could generate a file with 128KB of random generated data with dd, without a problem.

dd if=/dev/urandom bs=1024 count=128 of=myfile

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .