Saturday 1 February 2020

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


Long story short, I'm working on a Windows 7 machine and I'd like to strip the image off an SD card (backing up the card from a Raspberry Pi). I'm trying to use Cygwin, but not having much success.


Examining the /dev directory, it looks like my SD card is showing up as sdd and sdd1. However, when I run the following command:


dd if=/dev/sdd of=RPi.img

I get the following:



dd: opening '/dev/sdd': Permission denied



I've used dd on a Mac and under Linux without any problem, using similar syntax. What am I missing with Cygwin?



Answer



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

No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...