How to use Cygwin to copy an image from an SD memory card

You get the Permission denied error, because you are not root. That sounds strange in the context of Cygwin, but it hits home.

When you query your status (id) in a normally started Cygwin shell, you'll get something like that:

$ id
uid=1001(user) gid=545(Users) groups=545(Users),555(Remote Desktop Users),513(None)
$ dd if=/dev/sda bs=1000 count=1 | wc -c
dd: opening `/dev/sda': Permission denied
0

Under Windows 7 the trick to become root in Cygwin is to start the session elevated, that is, do a right click on your Cygwin icon and choose Run as Administrator. Now your are still not root itself, but at least in root's group:

$ id
uid=1001(user) gid=545(Users) groups=545(Users),0(root),544(Administrators),555(Remote Desktop Users),513(None)

And now, dd works as you are used to it from Un*x:

$ dd if=/dev/sda bs=1000 count=1 | wc -c
1+0 records in
1+0 records out
1000 bytes (1.0 kB) copied, 0.00104424 s, 958 kB/s
1000

I recently had to clone one USB drive to another on windows. My drive is a multiboot with additional software so I didn't want to just copy all files on the FS. DD was a clear choice, but I wasn't on linux so there were a few things I had to do to get it working.

I had cygwin installed and did the following.

first I had to figure out what /dev/sdX device my f: volume was. To do so run this command in cygwin. (TIP: Make sure you start cygwin with admin privs.. *Right click on cygwin and "Run as Administrator")

    cat /proc/partitions
which should output:
   8 0 3813383838 sda
   8 1       4031 sda3 C:\
   8 15  30588303 sdb 
   8 15  30588303 sdb1 E:\
   8 21  30530020 sdc
   8 22  30530020 sdc1 F:\

etc... Here you can clearly see for me to clone my F: drive to my E: drive I'd issue the following command.

There is one more step actually, you have to find the root of your device. Look for an sd* that has a size of your device. This whould be easy as the size should be well known such as 8GB, 16GB, 32GB expanded as bytes as shown above.

dd if=/dev/sdc of=/dev/sdb bs=8M

My image was 32gb.. and I didn't want to just sit and wait with a blinking cursor.. I wanted to see progress so I installed "pv" in cygwin.

dd if=/dev/sdc | pv | dd of=/dev/sdb bs=8M

Now if you want to copy the thumbdrive to an image do the following.

dd if=/dev/sdX | pv | dd of=/cygdrive/c/Users/Myname/Desktop/mythumbdrive.img bs=8M

Hope this helps


Will something like USB Image Tool do?
Or, do you insist on using Cygwin? ...

Tags:

Cygwin

Sd Card

Dd