20

For a project I'm working on I'd like to create a "stock" image based on Raspbian that I can install on many Pis.

Ideally I'd like to be able to (on my computer) take the Raspbian image, apt-get some packages, edit some config and then create and SD card image from that to put on my Pis.

Is there a simple or recommended way to do this? Any pitfalls I may encounter?

I am keen to avoid manually tinkering with a pi and then cloning that image. Presumably Raspbian is made in some way that isn't someone manually clicking buttons on a Pi. I'd like to do it that way, if I can.

Ideally I want to create something that can be automatically built on an continuous integration server - I don't want a build process that involves "write an SD card, put it in a Pi" because I want to be ale to create images without any physical access to a Raspberry Pi.

techraf
  • 4,353
  • 10
  • 32
  • 43
Andy Smith
  • 432
  • 1
  • 5
  • 19

4 Answers4

6

The Raspberry Pi foundation uses a set of bash scripts automating QEMU to generate their images. You should still look into the "industry standards" buildroot and Yocto too.

https://github.com/RPi-Distro/pi-gen

http://cellux.github.io/articles/diy-linux-with-buildroot-part-1/

flakeshake
  • 6,244
  • 1
  • 16
  • 35
5

My project Nard SDK has many of the features you want. It's not Raspbian but it has Raspbian binary emulation and are thus very close. With Nard you build everything on a PC and the process is very fast and reproducible. Everything is scriptable and can be done by e.g. a nightly continuous integration.
http://www.arbetsmyra.dyndns.org/nard/

Ronny Nilsson
  • 878
  • 5
  • 13
0

I think what you are looking for is some kind of (software) configuration management. With this you would be able to boot up a stock raspbian image and then push over your own configuration (including new packages and the like). There are plenty of SCM systems out there. The downside is that most of these systems are aimed to support large scale networks and so are maybe a bit overkill for your purpose. You also need some kind of provisioning server. Most popular SCM's seem to be Puppet, Chef, Ansible. Articles to get you started:

This is kind of a generic answer but SCM is a wide field. Maybe this is worth digging into depending on what your plans are.

duenni
  • 111
  • 4
-1

In my opinion, doing it in the way you suggested (mounting, doing workarounds for updating and configuring, etc.) presents more challenges than actual solutions. Sure, it may be fun to do it your way if you're interested, but the best and easiest way may be the one you're avoiding.

I recommend you get a Pi and do what you have to do on it, then make an image of its SD card. Then, use that image on your other Pis since that image is already configured.

Note: I'll assume you'll use Raspbian. I'll also assume you're just an average person and not some person who prepares images on a frequent basis (e.g. Raspberry Pi Foundation).


Steps if you do tinker with your Pi:

  1. Download and install fresh OS image of your choice
  2. Plug in Ethernet cable/connect to WiFi
    • Possibly do a LAN scan if you don't know your Pi's IP addres
  3. Do stuff via SSH
    • apt-get update -y && apt-get upgrade to update packages
    • Your personal configuration needs
  4. Make an image, then use that image for other Pis.

Steps if you don't tinker with your Pi (see note above):

  1. Download fresh OS image
  2. Mount image using instructions from https://raspberrypi.stackexchange.com/a/13138/24224 (you also have to consider what OS/image you have since some have different FS layouts)
    • Have a calculator ready.
  3. Find the deb file for each and every package you want to update, plus their dependencies, plus those dependencies' dependencies, plus those dependencies' dependencies' dependencies. apt-offline is a hassle. Refer to this link
    • Then find a way to install all of those packages without using/tinkering with your Pi. apt-get won't work offline. deb file details here. Good luck.
  4. Update the Pi kernels and low-level stuff using Hexxeh's tool
  5. Configure to your requirements
  6. Write modified image to your Pis' SD cards.

I don't see any benefit in not tinkering with your Pi.

Cut yourself some slack and tinker with your Pi. You only have to do it once.

Aloha
  • 7,176
  • 1
  • 29
  • 52