Table of Contents
Raspbian installation
Download
Visit https://www.raspberrypi.org/downloads/raspbian/ and locate the latest download image.
Fetch the image.
wget https://downloads.raspberrypi.org/raspbian_lite_latest
Verify the file with the hash on the download page.
sha1sum 2018-10-09-raspbian-stretch-lite.zip fe99e1c4e64c44a67468889e64d732f601968e87 2018-10-09-raspbian-stretch-lite.zip
Decompress.
unzip 2018-10-09-raspbian-stretch-lite.zip
Install
Place a microsd card in your desktop system and write the image.
In this instance, the microsd card is detected as sdd.
sudo dd if=2018-10-09-raspbian-stretch-lite.img of=/dev/sdd bs=4M
Initiate a rescan of the device.
su root -c 'echo 1 > /sys/block/sdd/device/rescan'
Edit config
Mount the RPi boot partition and make some changes.
su -m mount /dev/sdd1 /mnt vi /mnt/config.txt
Some example options for config.txt.
sdtv_mode=2 #dtparam=audio=on gpu_mem=16 dtparam=spi=on dtoverlay=spi-bcm2835 #dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25 dtparam=i2c_arm=on dtparam=i2c_vc=on #dtoverlay=w1-gpio,gpiopin=4 #dtoverlay=dht11,gpiopin=17
Enable network login for default user.
touch /mnt/ssh
Un mount the boot partition.
umount /mnt
Edit networking
Mount the system partition and set up networking. This will allow us to login after the Pi boots and finalise the set up.
mount /dev/sdd2 /mnt vi /mnt/etc/network/interfaces vi /mnt/etc/resolv.conf
Protect resolv.conf from errant applications which may wish to break it.
chattr +i /mnt/etc/resolv.conf
Un mount the system partition.
umount /mnt
Boot Pi and login to fix the O/S
It will take some time before the Pi is available, be patient.
ssh pi@X.X.X.X sudo -s
Update
apt-get update apt-get dist-upgrade
Install sysvinit and restart
apt-get install sysvinit-core sysvinit-utils sync reboot
Remove systemd
ssh pi@X.X.X.X sudo -s apt-get remove --purge --auto-remove systemd echo -e 'Package: systemd\nPin: origin ""\nPin-Priority: -1' > /etc/apt/preferences.d/systemd
Disable undesired services
update-rc.d dhcpcd disable update-rc.d motd disable update-rc.d triggerhappy disable update-rc.d cron disable update-rc.d dbus disable update-rc.d dphys-swapfile disable update-rc.d ntp disable update-rc.d avahi-daemon disable update-rc.d bluetooth disable update-rc.d plymouth disable update-rc.d paxctld disable
Edit /etc/inittab and disable unnecessary gettys and reboot.
Set up swap
Because we disabled the useless swap generator, do it by hand.
swapoff /var/swap dd if=/dev/zero of=/var/swap bs=4M count=512 mkswap /var/swap echo "/var/swap none swap sw 0 0" >> /etc/fstab reboot
Finish off
When we log in now we have a mean and lean linux installation but no service management. I prefer runit or you may prefer daemontools.
Set up runit/daemontools now as required and you are done.