Tiny Core Linux on Raspberry Pi

Sat 03 February 2018

Tiny Core Linux SSH screenshot

I'm discovering Tiny Core Linux, a beautifully executed, minimalist, immutable-by-default GNU/Linux distribution that runs nicely on the Raspberry Pi and other x86 and ARM devices.

The documentation is comprehensive but arcane so here are my field notes.

I'm using piCore the Raspberry Pi variant of TinyCore but most of these notes should work for other variants too. These notes assume you are already a GNU/Linux desktop user and know basic Linux command line fu.

Happy penguin jumping

I'm a huge fan of this distribution!

Official disk images.

Here's the official README for the Raspberry Pi version.

Write the disk image to your SD card

sudo dd if=piCore-9.0.3.img of=/dev/mmcblk0

Make sure you get your sd card's device (e.g. mmcblk0) correct so you don't overwrite the wrong disk!

Tip: you can see where dd is up to by sending it a signal:

sudo kill -SIGUSR1 `pgrep -f mmcblk0`

After this put the sd card into your Raspberry Pi and it'll boot Tiny Core Linux with an SSH server running so that you can access it remotely over the network.

Find the Pi on your network

find-pis: use this little script to find the Raspberry Pi on your network so that you can ssh to it.

Default login:

username: tc
password: piCore

Immutable by default

Tiny Core Linux is a perfect fit for Raspberry Pi because it does not write to disk by default. Note that between reboots if you want to persist any changes you've made, you need to do it manually with filetool.sh -b. You'll especially want to do this after first boot to persist the SSH server keys. This includes any changes you make to files in the home directory.

This lack of disk writes is a huge boon because it prevents issues that distributions like Raspbian have with SD card corruption when you power off the Raspberry Pi. Immutability is also just a good thing generally for building robust software systems.

Tiny Core Linux package repository

The packages are .tcz files which like most package formats are a zipped up collection of files with some metadata. You can browse the packages available to the Raspberry Pi distribution.

Various useful commands

Persist current state to disk:

filetool.sh -b

Where to specify additional default file locations for persistence:

/opt/.filetool.lst

Download and install packages (nodejs binary package in this example):

tce-load -wi node.tcz

Show which packages are currently installed:

tce-status -i

Install a package for doing C/C++ compilation & development:

tce-load -wi compiletc

Find current OS version info:

version

Search for and install packages with console UI:

tce

Where to put your own startup and shutdown scripts:

/opt/bootlocal.sh
/opt/shutdown.sh

Getting WiFi working

You'll want the packages wifi and firmware-rpi3-wireless and then reboot and set up a connection:

sudo wifi.sh

Don't forget to persist your changes.

Getting sound working

You'll want the alsa and alsa-utils packages.

I managed to compile Pure Data and output a basic test tone. I went into the src folder of Pd and issued make -f makefile.gnu to build it from the source after checking it out from git.

GPIO access

I managed to interface with the Raspberry Pi GPIO by installing node and then using the onoff package installed via npm. Lots of dev packages were required for a successful build (compiletc probably covers most of them). Each time npm threw an error I looked at what the error message was to determine which package to install next until it built successfully.

I managed to get an LED to blink on pin 16 with this code:

var Gpio = require('onoff').Gpio;
led = new Gpio(16, 'out');
led.writeSync(1);
c = 0
setInterval(function() { led.writeSync(Number(c = !c)); }, 1000);

I had to run node as root to get access to the GPIO.

Philosophical waxing

GNU/Linux has now been subsumed into the technological substrates of the world. It is found in most phones, servers and appliances that people interact with every day. There are probably 10 copies of Linux running in the median developed-world household. It has become infrastructure, like roads and wires and water pipes.

I don't see that many young people at GNU/Linux meetups these days. I don't think we GNU/Linux nerds are required by the world in the same way that we were before when it was sparkly and new.

It's exciting for me to find Tiny Core Linux which has re-ignited the spark of enthusiasm for this technology.