Making an image file from an SD card on Windows

28May12

I spent time figuring this out due to needing SD cards for my Raspberry Pi, but the instructions apply to pretty much anything on SD.

DD on Windows

Windows sadly lacks the DD utility that’s ubiquitous on Unix/Linux systems. Luckily there is a dd for Windows utility. Get the latest version here (release at time of writing is 0.63beta).

Which disk

Before using DD it’s important to figure out which disk number is allocated to the SD card. This can be seen in Computer Management tool (click on the Start button then Right Click on Computer and select Manage). Go to Storage -> Disk Management:

Here the SD card is Disk 1.

Making the image

First start a Windows command line as Administrator (hit the start button, type cmd then right click on the cmd.exe that appears and select Run as Administrator). Next change directory to wherever you unzipped the DD tool.

To copy the SD card to an image file (in this case c:\temp\myimage.img) use the following command line:

dd if=\\?\Device\Harddisk1\Partition0 of=c:\temp\myimage.img bs=1M

In this case we’re using DD with 3 simple arguments:

  1. Input file (if) is the SD card device
  2. Output file (of) is the image file we’re creating
  3. Block size (bs) is 1 megabyte

Writing the image back to a clean SD card

The first step is to ensure that the SD is complete clean. Most cards come preformatted for use with Windows machines, cameras etc. The diskpart tool can be used to remove that. Go back to your cmd running as administrator (and be very careful if you have multiple disks that you use the right number):

diskpart
select disk 1
select partition 1
delete
exit

You’re now ready to copy the image back to the SD (simply by swapping the earlier input file and output file arguments):

dd of=\\?\Device\Harddisk1\Partition0 if=c:\temp\myimage.img bs=1M


9 Responses to “Making an image file from an SD card on Windows”

  1. 1 Ben

    Hi there,
    I followed this the other day to back up a 2Gb card no problem, I have now modified another SD card 4GB runs perfectly on PI, but when i copy this one – I get this:
    error reading file 23 data error (cyclic redundancy error)
    3724+0 records in
    3724+0 records out

    any ideas how i can avoid this? thx

  2. 2 Ben

    I tried check card with win 7 tool and no errors found on card.. it loads and work properly too.
    tried after reboot, and no luck still… not sure what to attempt next

  3. 3 Ben

    Hi there, i managed to create an image with Linux Reader 1.6.4.. very straight forwards, right click and create image.. hopefully it copies property when i write… it.. maybe more help for others here with alternatives.

  4. Or you can use this software to create perfect disk image file from sd card. Check it here: http://www.roadkil.net/program.php?ProgramID=12&Action=NewOSID&DownloadVersion=9&Installer=NO

  5. 5 sudo

    What about “dd” on Cygwin? Was that out of the options? I am wondering if I would have to use 3rd party software rather than Cygwin.

    • dd on Cygwin would also work, but anybody that can get Cygwin installed probably doesn’t need to be told how to use dd

  6. 7 Bjarne

    I tried with following command:
    dd of=\\.\f: if=C:\ddimage\sd_2gb.img bs=1M –Progress

    It started to program and showed the progress and stopped without any errors.
    But in Computer Management it still says “1.84 GB raw”.
    I expected it was devided into 7 partition.

    If I use this:

    dd of=\\.\Device\Harddisk1\partition0 if=C:\ddimage\sd_2gb.img bs=1M –Progress
    I get a error: “0M Error writing file: 5 Access is denied

    • Win32DiskImager is generally much easier if you want to write an image onto an SD.

      • 9 Bjarne

        Thanks Chris
        I have used that, but I need something else because I have to make a automatik programming equipment for a production line and win32DiskÍmager don’t support commandline control.

        /Bjarne


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: