# How do I make a copy of a NOOBS SD card?

When we install Linux on Raspberry Pi with a NOOBS SD card, the original data on the card is erased as it becomes the storage device for the new system.

I have just bought a 16Gb NOOBS SD card, and I would like to make a copy on a blank 16Gb SD card, so that I can keep the original card as backup in case anything goes wrong and I want to repeat the installation.

Please, how do I go about that? I am running Fedora 20 on my PC, with zshell, and I have a USB SD card reader/writer.

Insert the card and figure out the dev node, I'll use /dev/sdb <-- Note there is no number here. This is the device, not the partitions on it.

sudo fdisk /dev/sdb


You'll get "Welcome to fdisk", etc. This is interactive. Press p. It will print a partition table. Here's what a recent Raspbian card would probably look like:

Disk 2015-01-31-raspbian.img: 3.1 GiB, 3276800000 bytes, 6400000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00092fac

Device                   Boot     Start       End  Blocks  Id System
2015-01-31-raspbian.img1           8192    122879   57344   c W95 FAT32 (LBA)
2015-01-31-raspbian.img2         122880   6399999 3138560  83 Linux


NOOBs will obviously be different but the principles are the same. This is actually from an image, not a real SD card, but that doesn't matter. You need two numbers. The first one is the number of bytes per block unit in the output:

Units: sectors of 1 * 512 = 512 bytes


It's probably 512. The other number is the end of the last existing partition:

2015-01-31-raspbian.img2         122880   6399999 3138560  83 Linux
^^^^^^^


Doesn't matter which one it is, just make sure that's the highest number in the table. Once you have those, q to quit.

To create a backup image of this card:

dd if=/dev/sdb of=backup.img bs=512 count=6400000


Notice the block size (bs) is 512 and the count is the end block of the last partition plus one (actually I think the +1 is unnecessary, but it won't do any harm to go over). Using a larger block size may speed the process up, but then you have to do a bit of math. M in GNU's dd is a MiB (check your man page if you are not using linux). To use bs=4M, 4 * 1024 * 1024 / 512 = 8192, which is what count should then be divided by, rounding up:

dd if=/dev/sdb of=backup.img bs=4M count=782


When it is done, you can verify by using fdisk on the image.

fdisk backup.img


p to print should show almost exactly the same thing as with the card itself (the total number of blocks will be different).

NOTE: Do NOT use this method to keep regular backups. dd is fine for creating images, but with regard to backing up filesystems it is like using a sledgehammer to make tea. That's not what it is for and you may come to regret it (in addition to it being preposterously slow and creating much unnecessary wear and tear on your backup media). Use a conventional method such as rsync, tar, or rsnapshot.

Unmount the card, then try:

sudo dd if=/dev/sdcardlocation of=backupimage.img.

Replace sdcardlocation with the location of your SD card.

You could swap .img with .dmg or .iso.

In case you need to do this on a mac and prefer a GUI:

1. Open /Applications/Utilities/Disk Utility.app
2. File > New Image > New Image from {Your noobs card}
3. Make sure to choose DVD/CD master from the type dropdown
4. Be patient, this takes a little bit of time for a 16GB SD card with slow read/write performance. (At least it did for me)