Backup/restore compact flash cards with Windows and Cygwin

In one of my side-ventures, which I’ve written about before, we develop and sell Linux and Java based nmea wireless navigation servers for the marine market. The devices run a small embedded Linux distribution on compact flash so we regularly need to write the image to new CF cards before sending out a new unit.

To setup a new batch of units I’d been using Linux and dd to write an image to the compact flash card. In a pinch I’ve also used VMWare with a virtual machine running Linux to do this job in the past.

However, this weekend I took a few new CF cards that needed to be imaged out of town along with my laptop determined to find a way to do it under Windows directly. Not surprisingly the answer was once again Unix in the form of Cygwin. I couldn’t find any way to do this with native windows tools. So for the 0.001% of you who read this blog and also need to backup/restore compact flash cards, here’s how you do it under Cygwin:

1. Figure out which Cygwin device the compact flash card is. To do this first insert the card that you want to backup and then run cat /proc/partitions. If you have a new 256MB CF card in your card reader you should see an entry like this: 249007 sdb. If could be sdc, sde, etc… but you should be able to identify the device based on the size of CF card in the slot.

2. To backup or make an image of a CF card (assuming /dev/sdb is your CF card) run dd if=/dev/sdb of=somefilename.dd bs=1M. Next do a chmod a-w somefilename.dd so you don’t accidentally overwrite the backup if you switch the if and of parameters in the next step.

3. Now when you get a new CF card that you want to write the image to, put the new CF card in the slot and run dd if=somefilename.dd of=/dev/sdb bs=1M.

Now your new CF card should be exactly the same as the old one. Ofcourse with Mac OS X and Linux, dd should already be installed on your system so you don’t need to install Cygwin.

This entry was posted in Systems Administration. Bookmark the permalink.

3 Responses to Backup/restore compact flash cards with Windows and Cygwin

  1. tillb says:

    Hey, here is one of the 0.001% 🙂

    Thanks for this hint, that’s exactly what i am looking for.

  2. Moot says:

    Is this applicable when there is another partition. For instance, I can see the following partitions in /proc/partitions:

    major minor #blocks name

    8 16 1015560 sdb
    8 17 1014785 sdb1

    Do I have to dd both of the partitions? Is sdb the MBR? Thanks!

  3. Todd Huss says:

    Moot, sdb is the device and sdb1 is a partition within the device. When you read via dd from sdb you’ll get all the partitions within sdb including sdb1. So you shouldn’t need to dd each partition separately.

Leave a Reply

Your email address will not be published. Required fields are marked *