Notes taken at build of Sbox20220116 (compatibility PI4 and upgrade Python 2.7 => Python 3 required a build from scratch). It's possibly not 100% accurate (nightly builds...) and may have had some corrections afterwards. Also: it's for Buster, which is outdated by now.. Some info first: ================ https://www.raspberrypi.org/documentation/computers/config_txt.html https://community.blokas.io/t/pisound-with-raspberry-pi-4/1238/12 https://www.hifiberry.com/docs/software/configuring-linux-3-18-x/ find /etc/systemd -name \*.service -type l -a -xtype f -printf %f\\n journalctl -axe dnsmasq config (add !): dhcp-leasefile=/var/lib/misc/dnsmasq.leases -> solved with ln below $ sudo apt-get install usbmount The following NEW packages will be installed: liblockfile-bin liblockfile1 lockfile-progs pmount usbmount 0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded. Need to get 142 kB of archives. After this operation, 666 kB of additional disk space will be used. sudo nano /etc/usbmount/usbmount.conf (filesystems) /lib/systemd/system/systemd-udevd.service Before: PrivateMounts=yes After: PrivateMounts=no The actions: ============ Install buster on 2Gb SD Start (buster autoresizes) Copy to >4Gb SD fdisk delete+define P2 with +4Gb, don't erase ext4 signature ! reboot, resize2fs $ sudo raspi-config: hostname samplerbox set password to sbox via sudo passwd pi $ sudo dpkg-reconfigure keyboard-configuration and then "other" -> US (generic) and reboot https://www.element14.com/community/community/raspberry-pi/blog/2019/09/14/asla-audio-glitch-issue-pi-4-fix https://linuxconfig.org/how-to-change-default-python-version-on-debian-9-stretch-linux https://setuptools.readthedocs.io/en/latest/python3.html Dependencies: sudo apt-get install python-dev libasound2-dev python-setuptools swig libportaudio2 libffi-dev python3-pip libatlas-base-dev ntfs-3g libjack-dev libjpeg-dev libopenjp2-7 libtiff5 midisport-firmware dialog sudo pip3 install cython psutil RPi.GPIO smbus sounddevice pyalsaaudio st7789 numpy 2to3 ===> ##rtmidi2 ===> # manual install rtmidi2 requires libjack-dev OLED: $ sudo -H pip3 install --upgrade luma.oled NTFS: fdisk: change type to "7" (HPFS/NTFS/exFAT) Format with: mkfs.ntfs -f /dev/sdx1 umount /samples mount /dev/mmcblk0p3 /samples <----------> Make it readonly: (https://medium.com/swlh/make-your-raspberry-pi-file-system-read-only-raspbian-buster-c558694de79) - Housekeeping $ sudo apt-get update && apt-get upgrade $ sudo apt-get remove --purge triggerhappy logrotate dphys-swapfile $ sudo apt-get autoremove --purge $ update /boot/cmdline.txt: add " fastboot noswap ro" - Replace your log manager $ sudo apt-get install busybox-syslogd $ sudo apt-get remove --purge rsyslog ... From now on use sudo logread to check your system logs - Make the file-systems read-only and add the temporary storage Update the file /etc/fstab and add the ,ro flag to all block devices (/boot and /) and add: tmpfs /tmp tmpfs nosuid,nodev 0 0 tmpfs /var/log tmpfs nosuid,nodev 0 0 tmpfs /var/tmp tmpfs nosuid,nodev 0 - Move some system files to temp filesystem Note: This part is different from previous Raspbian versions (Stretch etc.). On Raspbian Buster do NOT move the /var/lock and /var/run directories as they are already symlinked to tmpfs directories. You can read more about these changes in the Debian Buster tmpfs documentation. $ sudo rm -rf /var/lib/dhcp /var/lib/dhcpcd5 /var/lib/misc/dnsmasq.leases /var/spool /etc/resolv.conf $ sudo ln -s /tmp /var/lib/dhcp $ sudo ln -s /tmp /var/lib/dhcpcd5 $ sudo ln -s /tmp/dnsmasq.leases /var/lib/misc/dnsmasq.leases $ sudo ln -s /tmp /var/spool $ sudo touch /tmp/dhcpcd.resolv.conf $ sudo ln -s /tmp/dhcpcd.resolv.conf /etc/resolv.conf - Update the systemd random seed Link the random-seed file to the tmpfs location: $ sudo rm /var/lib/systemd/random-seed $ sudo ln -s /tmp/random-seed /var/lib/systemd/random-seed Edit the service configuration file /lib/systemd/system/systemd-random-seed.service to have the file created on boot. Add the line ExecStartPre=/bin/echo "" >/tmp/random-seed under the [Service] section. The modified [Service] section should look like this: [Service] Type=oneshot RemainAfterExit=yes ExecStartPre=/bin/echo "" >/tmp/random-seed ExecStart=/lib/systemd/systemd-random-seed load ExecStop=/lib/systemd/systemd-random-seed save TimeoutSec=sudo pip install psutil30s - get rid of rfkill: https://unix.stackexchange.com/questions/597292/how-to-disable-rfkill-after-it-has-been-uninstalled-from-raspbian sudo systemctl disable rfkill sudo systemctl stop rfkill echo "rfkill" | sudo tee -a /etc/modprobe.d/raspi-blacklist.conf sudo mv /lib/systemd/{systemd-rfkill,system/systemd-rfkill.{service,socket}} ~ echo "0" | sudo tee /var/lib/systemd/rfkill/* Inside /lib/systemd/system/raspberrypi-net-mods.service, I commented out: #After=systemd-rfkill.service And finally appended "systemd.restore_state=0 rfkill.default_state=1" to /boot/cmdline.txt At this point after rebooting you should have a working Raspberry Pi in read-only mode <----------> - Useful commands: Edit the file (/etc/)bash.bashrc and add the following lines at the end: set_bash_prompt() { fs_mode=$(mount | sed -n -e "s/^\/dev\/.* on \/ .*(\(r[w|o]\).*/\1/p") PS1='\[\033[01;32m\]\u@\h${fs_mode:+($fs_mode)}\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' } alias ro='sudo mount -o remount,ro / ; sudo mount -o remount,ro /boot' alias rw='sudo mount -o remount,rw / ; sudo mount -o remount,rw /boot' PROMPT_COMMAND=set_bash_prompt cd /home/samplerbox - misc set root password to sbox sudo passwd sudo systemctl disable bluetooth doesn't work, see https://scribles.net/disabling-bluetooth-on-raspberry-pi/ sudo apt-get purge bluez -y sudo apt-get autoremove -y copy & "sudo python setup.py install" for: rtmidi2, python-midi # pyalsaaudio mkdir /samples & chown to pi sudo systemctl disable raspi-config (..disable system governor) ..don't do: systemctl disable avahi-daemon (..disable discovering network services), but: sudo systemctl disable avahi-daemon.socket sudo systemctl disable avahi-daemon.service sudo systemctl disable systemd-timesyncd sudo systemctl disable systemd-journald sudo systemctl disable cron (..disable job scheduling) sudo systemctl mask rpi-eeprom-update (..use unmask to undo) sudo systemctl disable apt-daily.service sudo systemctl disable apt-daily.timer sudo systemctl disable apt-daily-upgrade.timer sudo systemctl disable apt-daily-upgrade.service sudo systemctl disable rsync ===> check path statement in smfplayer.py sudo apt-get install zerofree (for restricting the size of the downloadable image. See http://frippery.org/uml/index.html and http://manpages.ubuntu.com/manpages/xenial/man8/zerofree.8.html)