Inspired by https://0pointer.net/blog/fitting-everything-together.html
- ESP (
/efi) partitionboot.imgthat contains RPi firmware & config + EDK2 firmware with Secure Boot using our custom cert (mkosi.crt)boot.sigsigned withmkosi.key.mkosi.crtshould be included in EEPROM (usingrpi-eeprom-config) to make the boot chain secure- Unified Kernel Image (UKI), signed with
mkosi.keylinux-image-genericfrom the distributionnvmem-raspberrypi-otpkernel module from raspberrypi/linux
- Readonly
/usrpartition- Debian Trixie distribution, other systemd>=256 distros should work too
- "Golden"
/etcstored into/usr/share/factory/etc - verity & verity-sig partitions make sure the contents are not tampered with
- Create encrypted root partition
- passphrase from RPi eeprom OTP registry
/etcpopulated from/usr/share/factory/etcusingsystemd-repart'sCopyFiles=- other root directories & files populated with
systemd-tmpfiles(no custom configuration)
- Create 3 empty matching-size partitions (labeled
_empty) for/usrupdates
NOTE: This is default behavior of systemd-sysupdate
- After 15 minutes of uptime, query updates from GitHub releases using
systemd-sysupdate- Download the new
usr+verity+verity-sigpartitions directly into the_emptypartitions - Download the new UKI to
/efi/EFI/Linux/system_x.x.x.efi
- Download the new
- Periodically check if a new version is installed
- if found, reboot
- if reboot fails, auto-rollback to previous version (untested!)
- if found, reboot
Everything is done inside virtual machine since we need quite recent systemd + previously mkosi required root access.
vagrant up
vagrant sshmkosi --directory="" genkey
# If using Vagrant with rsync, copy keys back to host so you don't lose them
cp mkosi.key mkosi.crt /vagrant/
mkosi
mkosi vm