====== Minimal Raspberry Pi system image ======
* Flash up to date image on sd card.
* Touch ''ssh'' in the ''boot'' partition
Connect to your pi, then run the following as root:
# Change the system logger
apt-get install -y busybox-syslogd && apt-get purge -y rsyslog
# Disable audio, wifi and bluetooth
echo "dtoverlay=pi3-disable-wifi" >> /boot/config.txt
echo "dtoverlay=pi3-disable-bt" >> /boot/config.txt
sed -i 's/dtparam=audio=on/#dtparam=audio=on/' /boot/config.txt
# Purge unnecessary packages
apt-get purge -y avahi-daemon bind9-host bluez bluez-firmware dphys-swapfile geoip-database libavahi-common-data libavahi-common3 libavahi-core7 libbind9-161 libdaemon0 libdns1104 libfstrm0 libgeoip1 libisc1100 libisccc161 libisccfg163 liblmdb0 liblwres161 libnss-mdns libprotobuf-c1 pi-bluetooth triggerhappy wpasupplicant
# Delete the swap file
rm -f /var/swap
# Switch to fastboot
sed -i 's/rootwait/rootwait fastboot noswap/' /boot/cmdline.txt
sed -i 's/console=serial0,115200 //' /boot/cmdline.txt
# Disable HDMI on startup
echo "/usr/bin/tvservice -o" >> /etc/rc.local
# Disable unneccesary services
systemctl disable keyboard-setup.service
systemctl disable rpi-eeprom-update.service
===== Read only =====
# Move some system files
cp /etc/resolv.conf /tmp/dhcpcd.resolv.conf
rm -rf /var/lib/dhcp /var/lib/dhcpcd5 /var/run /var/spool /var/lock /etc/resolv.conf
ln -s /tmp /var/lib/dhcp
ln -s /tmp /var/lib/dhcpcd5
ln -s /tmp /var/run
ln -s /tmp /var/spool
ln -s /tmp /var/lock
ln -s /tmp/dhcpcd.resolv.conf /etc/resolv.conf
# Update dhcpcd5.service
sed -i 's/PIDFile=\/run\/dhcp/PIDFile=\/var\/run\/dhcp/' /etc/systemd/system/dhcpcd5.service
# Update the random-seed unit file
mv /var/lib/systemd/random-seed /tmp/random-seed
ln -s /tmp/random-seed /var/lib/systemd/random-seed
sed -i '/^\[Service\]$/a ExecStartPre=/bin/echo "" >/tmp/random-seed' /lib/systemd/system/systemd-random-seed.service
# Update fstab
grep '\/tmp' /etc/fstab &> /dev/null || echo "tmpfs /tmp tmpfs nosuid,nodev 0 0" >> /etc/fstab
grep '\/var' /etc/fstab &> /dev/null || echo "tmpfs /var/log tmpfs nosuid,nodev 0 0" >> /etc/fstab
grep '\/var\/tmp' /etc/fstab &> /dev/null || echo "tmpfs /var/tmp tmpfs nosuid,nodev 0 0" >> /etc/fstab
# Reload systemd units
systemctl daemon-reload