Our custom Raspbian image for tutorials

For each Cotswold Raspberry Jam, I produce a custom version of the Raspberry Pi’s Raspbian operating system, all set up ready for tutorials and other projects at the event. You can download the one for our Sat 2 July 2016 event (1GB .zip) using Bittorrent:

http://www.cotswoldjam.org/downloads/2016-07/cjam-tutorial-20160701-raspbian-image.torrent

Bear in mind that if you’re attending the event, we’ll have plenty of ready-made SD cards for you to borrow (or buy for a fiver), so this isn’t a prerequisite for attendees.

I recommend downloading using Transmission for Mac & Linux or Transmission for MS-Windows, but any well-behaved Bittorrent client will do.

After downloading, follow the instructions on how to install a Raspberry Pi operating system image. You’ll need at least a 4GB micro SD card, and any files already on that card will be erased.

Your Raspberry Pi will automatically reboot once only when it first uses our image. Details below, but essentially you don’t need to worry about it. The username and password remain the same as normal Raspbian; username pi with password raspberry .

Our custom image features:

  • Raspbian Jessie, up-to-date as of the week it was produced, including GPIO Zero
  • All the tutorial files
  • All libraries & programs set up for our tutorials
  • WiFi set up for our event (you’ll need a WiFi adapter or Pi3)
  • 1GB zipped and under 3GB unzipped; Wolfram Alpha and Libreoffice have been removed to reduce the size of the image
  • MT Paint graphics editor, Abiword wordprocessor, GNUmeric spreadsheet, Eye of Gnome image viewer / slideshow, FBI framebuffer image viewer / slideshow, VNC server & client have been added

In addition, we have a fancy automatic setup system. I’ll blog about that later (follow @CotswoldJam on Twitter). In brief, for the first time the image is booted (and not subsequent boots):

  • From rc.local , it checks for the existence of the file /boot/1stboot.txt – if it can’t find it, it does nothing and exits
  • It deletes /boot/1stboot.txt so it doesn’t do the process ever again
  • It expands the filesystem to fill the whole SD card
  • It sets the hostname to rpi-XXXX where XXXX is hopefully unique
  • It reboots

This is why our image will reboot automatically when first used. This reboot should happen before the desktop appears (hopefully; I could really do with moving the script from rc.local to a proper systemd target).

XXXX is the last 4 digits of the SD card’s CID serial number. The CID should be unique to each and every SD card (if it isn’t, you’ve probably got a fake card). CIDs were originally designed to provide copy-protection for big music & movie companies – there’s a certain satisfaction in subverting it for use with free software for a children’s hacking club.

By setting a (hopefully) unique hostname, we can address any of the Raspberry Pis at our event, over the network, individually. This is done with Avahi/Zeroconf/Bonjour, a standard which (amongst other things) allows computers on a local network to find out each other’s IP addresses using hostnames without having to use a domain name server.

I’ve written a few command-line scripts to help manage this, and to browse the network for Zeroconf domains. I’ve also written a nice script to fully automate the process of squishing an SD card image down to minimum size (oh boy, does an SSD make a difference) and I have some tips on mass duplication of SD cards. I’ll explain in more detail in another blog post, and publish the scripts, hopefully next week.

— Andrew Oakley

Posted in News, Tutorials
3 comments on “Our custom Raspbian image for tutorials
  1. Great work 🙂
    Looking forward to the build scripts as I always include Samba on my images 🙂
    I didn’t know about SD card serial numbers but I use a similar scheme which is the last 4 digits of the Pi Serial number – I’ll have to mull over the pros/cons of which one to use now 🙂

    Simon

    • Originally the script used ethernet MAC addresses by default. This made it cross-platform but once we got more than about half a dozen Pis in our tutorial fleet, it became unmanageable trying to match up SD cards to machines; not to mention the Pi Zero that turned up with no ethernet port. I kept the MAC address code in the script but it only triggers on a command line switch or config file.

      I did also try giving each Pi a name and creating a list of CIDs->hostnames , sort of like /etc/hosts but downloadable from a central webserver using curl. Again that became very tiresome very quickly, as we used some branded but low-end cards which had about a 10% failure rate, requiring us to swap out cards; keeping the list up-to-date got old very fast.

      Once we got to more than 15 tutorial machines, and in other developments also loaning out / selling SD cards at the events, I finally gave up and accepted that there was no realistic chance that I could tie SD cards to physical machines.

  2. Samba would be an interesting choice for an event where we cannot predict what hardware devices attendees will bring along. Personally I have found Samba config files to need changing every 6-18 months or so, as Microsoft bring out new OSes or service packs which suddenly break compatibility with configs (or decide to go on a go-slow). My concern was that Samba would be wonderful for the one person that had exactly the same Windows version as my work laptop and gaming desktop, but a nightmare for everyone else, including my own Linux netbook and workstation 😉

    For file transfers at the event, we use mainly two methods:

    * SFTP / SCP / SSH file transfer – requires only OpenSSH Server (and Avahi / Zeroconf if you want to make use of hostnames)
    * USB keys / memory cards with card reader

    USB keys are particularly easy since the B+ onwards seems quite tolerant of USB insertion & removal. On older Pis, they crash unless you insert/remove with it powered off.