Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So finally I can place that bulk order for Raspberry Pis! However, configuring them is going to be a chore. What I'd like to do is:

  1. Download a stock image, and tinker with it on a single Pi
  2. Save/extract/copy that image to all the other SD cards
  3. Have the other Pi's all set up without any additional config needing to be done

My computer only has a single SD slot, so is there a way to generate a .img file from my modified 'master' card?

share|improve this question
Tom check out this post raspberrypi.stackexchange.com/questions/311/… I think it answers your question. – Steve Robillard Jul 16 '12 at 14:30
@SteveRobillard +1 That will answer the question perfectly. – Jivings Jul 16 '12 at 15:22
One thing to be aware of is SSH. If you set up SSH on the master you will end up with cloned SSH certificates on all of the images, which isn't necessarily what you want. OTOH, if you are going to be using the Pis headless, you probably do want SSH installed... – darrenjw Jul 16 '12 at 17:06
@darrenjw That is an extremely good point. You've saved me some embarrassment and no mistake. Thank you. – Jivings Jul 16 '12 at 19:28
Depending on how you intend to use that mass of Pis you may want to check out Andrew Mulholland's Raspi-LTSP project. It's not just useful for classroom use - it's also very good for clusters. – Dave Jones Nov 13 '14 at 11:50
up vote 5 down vote accepted

There are a couple of easy prep steps to do before writing a clone master to copies which will save you a lot of headaches.

  1. Configure the clone master for DHCP
  2. Delete everything in /etc/ssh/ssh_host* (these get recreated when you run SSHD)
  3. if you have an /etc/udev/rules.d/70-network* file, you'll need to modify the eth0 entry to something else (I used eth9 for my clone masters) - and remember to update the associated ifconfig file - in centos that is /etc/sysconfig/network-scripts/ifcfg-eth0 (make it 9) and in debian (raspbian) it's /etc/network/interfaces
share|improve this answer

You could use the Raspberry Pis themselves along with multixterm on your main computer to "boot strap" your SD card writing. You should be able to find multixterm in many distro's package managers.

Step 1: Buy a bunch of the USB stick SD card adapters.

Step 2: Use the standard methods to write 2 of the SD card images with your main computer.

Step 3: Put the 2 SD cards with images into 2 Raspberry Pis and get them connected to your network and powered up.

Step 4: Put 2 empty SD cards into the USB stick adapters and plug them into the 2 running Rapsberry Pis.

Step 5: Now here's where it gets interesting, from your main computer use multixterm like so from the command line multixterm -xc "ssh %n" host1 host2 where host1 and host2 are the ip addresses of the Raspberry Pis.

Step 6: Inside of multixterm's stdin window you can use dd as you normally would to write images to the SD cards but now multixterm will send that dd command to both Raspberry Pis simultaneously.

Step 7: Repeat steps 3-6 until you have all of your cards written.

The more SD cards you image the more Raspberry Pis you can use to image new SD cards. Obviously this technique won't write all of your cards in one go, but it would cut back on the amount of time it takes to complete writing all of the cards. This technique would be largely experimental so your mileage would vary, but the theory of it sounds like an interesting experiment...

share|improve this answer
Very interesting - but also very expensive for mass scale =) hehe love it. Is there no way to hyper thread writing images in different consoles to different USB SD adapters maybe? – ppumkin Nov 1 '12 at 10:12

What you are looking for is a Gang Programmer device for SD cards, or SD Card Duplicator.

Yes, these systems do exist. Here is one that I found by Googling "sd card gang programmer". This specific device has a master slot, which it can copy up to 7, slave SD cards at once. Other programmers with 3 or 11 slave slots are also available.

There are also different types of programmers. Some can flash an image from your hard drive and is controlled by software installed on a PC. Other devices, like the one linked above, do not have to interface to a servers because they mirror the information off of a master chip.

It is worth mentioning that these devices are not cheap. They are typically used in a mass production environment and demand isn't excessively high. Be prepared to pay at least $1,000 for a good device with this functionality.

ProDuplicator.com appears to have quite a few more SD Card duplication options, as well.

share|improve this answer

We had a similar requirement for a project where we needed to be able to write images to 10+ Raspberry Pi SD cards on a daily basis. We looked at the various Card Duplicator's available to buy but found most of them won't successfully make a bootable SD card, as most only copy files directly and not the bootable information, they are also ridiculously expensive!

So as a solution we wrote our own simple web-based software to run on a single Raspberry Pi connected to 2 x 7-port Belkin powered USB hubs (The Pi has a limitation of 2 hubs, and a maximum of 14 USB ports).

We've now released this as Open Source software to help others who have the same requirement. Currently just the source code is available but we will also be uploading an image file based on Arch Linux ARM running Nginx + php


share|improve this answer

I had the same requirements as 1 and 2 to distribute a customized OS. After looking around I found many commands, but not a single tool to create a compact .zip file from an SD card, so I wrote mkimg.sh, which works like this:

sudo bash mkimg.sh /dev/sda sdcard.img.zip

This takes the unmounted device at /dev/sda, shrinks down the filesystem and partition, and writes out a compressed zip. In my use, this writes a ~1.5GB Raspbian system to create a <500MB .zip.

Along with sanity checks and size calculations, the script essentially does this:

e2fsck -f /dev/sda2
resize2fs -M /dev/sda2
parted --align optimal /dev/sda unit MB resizepart 2 1700 yes
dd bs=1M if=/dev/sda of=sdcard.img count=1900
zip sdcard.img.zip test.img
parted /dev/sda resizepart 2 16.0GB
resize2fs /dev/sda2

The script and documentation is available on GitHub.

share|improve this answer

Although How do I backup my Raspberry Pi? provides excellent instrictions on how to clone a single SD card, doing it one at a time for dozens of cards will get tedious.

Given that no-one seems to have produced a multi-card SD card reader (one that can hold multiple SD cards at once) and the fact that that you can buy a USB hub and a bunch of single SD card USB readers very cheaply, one way to speed up the process would be to make your own SD card duplicator.

You could even write a script to automatically write your chosen Raspberry Pi image onto any empty SD card slot inserted in a slot. Scripts could automatically detect that a card has been inserted and indicate when the copy completes.

As darrenjw mentioned in comments though, you will want to replace the ssh certificates in each of the cloned images the first time they are booted, so you may want to make sure that this first boot is done while connected to a private network segment before connecting it to an internet connected network.

share|improve this answer
You don't normally mount a card to flash an image onto it. – Alex Chamberlain Jul 17 '12 at 12:26
Thanks @AlexChamberlain, I've still got a couple of weeks before my Pi is supposed to arrive (Grrr, if I'd known I was on an RS waiting list for a long lead time I would have just ordered from Farnell with a long lead time in the first place) so I haven't actually tried this yet. – Mark Booth Jul 17 '12 at 12:34

There are usually better tool to do this, then to copy a lot of RP images.

But it depends on what you really want to do.

You should have a look at cfengine3[1], fai[2], chef[3], fabric[4] or puppet[5]. They are automatic configuration tools, which would be usefull for doing stuff in your machine when started first time (and later).

[1] http://cfengine.com/ [2] http://fai-project.org/ [3] http://www.opscode.com/chef/ [4] http://www.debian-administration.org/articles/671 [5] http://puppetlabs.com/puppet/puppet-enterprise/

share|improve this answer

This works on Mac OS X.

Unmount the card that you have tinkered with, 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.

Next, to get the other cards ready, unmount them, and run the previous code with the values swapped round. The line would be this:

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

Make sure to unmount them before you take them out of the card reader.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.