1. Introduction
I have two Raspberry Pi 4 which do not have any purpose currently. I bought them a while ago to learn Kubernetes with `K3s`, and that mission is now complete. As I think that minimalism and simplicity will save us all (hopefully!), I want to explore how minimal of a Linux I am able to install on the RPi.
This will be a more or less accurate log of my progress and may be a bit chaotic here and there as I jump forth and back. So please read first before you try, to see if it makes sense to you :)
Project goals
- use an SD card friendly file system for the partition holding the OS (the boot partition has to be `vfat` though), disable `atime` and `nodiratime` (access time stamps) for all partitions to preserve life time of SD card
- make the boot partition as small as possible and include indispensable files only, it still needs enough free space to hold a second kernel whenever I want to upgrade
- do not use any Linux distribution, compile everything from scratch
- static builds only, no dynamic linking at all (I think `glibc` doesn't support that entirely, so need to look into `musl` or `dietlibc`)
- configure the Linux kernel to be as minimal as possible (disable support for modules, no initramfs, ...) and tightly adjust the settings to exclude everything that's not indispensable
- optimise boot times to be as fast as possible (kernel configuration, EEPROM settings, `config.txt`, ...)
- in spite of all the minimalism I still want to end up with a completely usable system, compile and run Xorg and Blender to prove that point
- overclock the RPi without risking damage or stability (I've already attached additional heat sinks and a small fan, so I should be able to overclock somewhat)
- although there's initial cross-compilation needed using my existing x86 Debian Linux PC, I want to end up with a system which can completely compile itself
- make use of hardware H.264 decoding capabilities
- use `vcgencmd` for temperature monitoring (lm-sensors is inaccurate) [1]
- do not use swap at all, as this can reduce the lifespan of the SD card [2]
Ideas & notes:
- try `F2FS` as file system for OS partition
- for initial Linux setup it's probably helpful to check the LFS (Linux from scratch) documentation
- try to compile kernel with musl instead of glibc, although this should have minimal effect
- set USB enumeration delay time as short as possible [3]
- use a smaller init system
- `/dev` should be as minimal as possible
- replace `coreutils` with something smaller, see [4] and [5]
- remove everything in `/etc/group`, `/etc/passwd`, and `/etc/shadow` which is not immediately needed, maybe do a search on the filesystem to find all users and groups in use, understand their purpose
Questions:
- is permanent "performance" CPU governor sustainable?
- do I want RTOS (real time OS) patches for the Linux kernel?
- if we can't use anything else than the `ext` family of file systems for the OS partition, should we switch off journalling to preserve life time of SD card?
- can we get rid of most, if not all overlay files on the boot partition? I've seen on a previously installed Debian that it doesn't come with those files, so we need to check if they're optional. If not, only keep indispensable files
- the H.264 capability on the RPi 4 is only decoding, right (no encoding)?
- does the kernel compile with `tcc`?
- in general, should we keep using `gcc` or switch to a smaller compiler? (`tcc`, ...?)
- there's a copy of the kernel located in `/boot` and another one in `/boot/firmware`, can we remove the former one?
- can we use uncompressed kernel image?
- can we speed up `IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready` step at boot?
- if we don't use any package manager, how can we track installed files per component for easy uninstall?
- what IO schedulers do we want to use for which media? [6]
[1] Measuring Temperatures
[2] Debian Wiki
[3] Using ‘delay_use’ to speed up USB Enumeration
[4] Core utilities alternatives
[5] suckless.org 9base
[6] Selecting a Linux I/O Scheduler
➡ 2. Making a plan
⬆ The minimal Raspberry 4 project
🏠 callistix Gemini capsule
Created: 6/Jan/2024
Modified: 9/Feb/2024