7 ms·
Rolling your own minimal embedded Linux for the Raspberry Pi
- ggm 5y agotypo in early commands of the form mkdir -p staging boot (space should be /) also, busybox doesn't demand symlinks: you can use hardlinks.
- bitwize 5y agoSystemd and dbus are standard parts of the Linux userland now, nearly as essential as the kernel itself as they provide vital services.
- detaro 5y agoPlenty embedded projects developed today don't use them (and functional desktop and server distros without them are around), "nearly as essential as the kernel" is really overstating it.
- igetspam 5y agoWe'll be headed down this path soon for some custom appliances. I can't find a compelling reason for systemd or dbus.
- deleted 5y ago[deleted]
- fragmede 5y agoThe fact that desktop Linux systems mostly run systemd is (unfortunately) a reason to run a Linux distro that also runs systemd on new embedded projects (for large values of embedded. Storage is cheap these days, as is a CPU with an MMU).
- kbaker 5y agoIf you can fit it in your image, systemd is amazing for embedded. Dependency tracking, auto service restarts on crash, unified start/stop and enable/disable, even journald is nice with per-unit unified logging. It is miles better than SysV or monit. I haven't needed to try the 'suggested' replacements like runit or openrc.
- igetspam 5y agoWhich are all great festures for devices where you'll have interaction. Auto restart on failure has been done for years, so the weight of systemd doesn't justify it for us. We'll have a single binary service, so dependency tracking isn't really a problem. Same for journald. 100% of the useful logs will be moved off the device, so the system journal isn't useful. Not every nail needs to be hut by the systemd hammer. We've had really fantastic and light weight init systems for decades without all the bloat and creep of systemd.
- wryun 5y agoAlternatively, you can use Void Linux and most of the work is done... admittedly, no read only fs by default.
- sigjuice 5y agoA couple of suggestions for minimal systems for the Raspberry Pi: https://buildroot.org https://buildroot.org build the whole Linux system from source https://gokrazy.org https://gokrazy.org pure-Go userland for your Raspberry Pi 3/4 appliances
- 01100011 5y agoDon't forget Yocto(guide here: https://medium.com/nerd-for-tech/build-your-own-linux-image-for-the-raspberry-pi-f61adb799652 https://medium.com/nerd-for-tech/build-your-own-linux-image-...).
- redleader55 5y agoI think this should be the real tutorial here. The amount of flexibility that Yocto brings is huge compared to anything else you can do from any other distribution.
- synergy20 5y agowhat's the usage of memory/storage comparing to buildroot for similar functionalities? I would expect something like 10x larger but I never measured it.
- Cyberdog 5y agoAlternatively, if you're not stuck on Linux, just install OpenBSD or NetBSD. Both will try to install X by default, but you can easily disable this in the TUI installers. After a reboot you'll go straight to a shell with very few daemons running (and certainly no systemd). Install the packages you need and start the daemons you need from there. Imagine having the entire output of `top` fit in a terminal window with empty space at the bottom.
- deleted 5y ago[deleted]
- seemaze 5y agoI do just this with Alpine Linux. I've been running it on Raspberry Pi Zeros with great success, and less than 18MB read only ramdisk.
- boring_twenties 5y agoI really wanted to like Alpine, but I can't for the life of me understand why it wants to do a ramdisk instead of just plain old read-only filesystem?
- riobard 5y agoRAM disk is way faster and more reliable than SD cards. You can even remove the SD cards after boot.
- boring_twenties 5y agoEverything that's used should be cached in RAM, anyway. Everything that isn't used, well, I prefer that not to be in RAM. These things don't exactly have gobs of it. And why would I want to remove the SD card after boot? Now I can't reboot the system, and it won't reboot if it crashes?
- riobard 5y ago
- traceroute66 5y agoRolling your own minimal embedded Linux is all cute fun. But what about maintaining it ? Assuming you're not going to be rebuilding the whole lot manually each time, you're also going to have to go through the rather cute experience of building (and maintaining) your own automation tooling around maintaining your minimal embedded Linux. If I were developing an embedded project, I don't know about you, but I would suggest focusing on the project itself might be a nice idea, not wasting time on things like a custom OS. Custom OS is fine if you've got a large team working along side you. But if its a one-man-band (or small team) then all the cuteness will soon evaporate. If you think all Linux distros are too bloated, why not go BSD instead ? For example, OpenBSD is famous for a minimal default install, and guess what, they maintain ready-to-go builds for Pine 64/64+, Raspberry Pi 3 and Raspberry Pi 4.[1] [1] https://www.openbsd.org/arm64.html https://www.openbsd.org/arm64.html
- PragmaticPulp 5y agoThe Raspberry Pi is a learning platform, first and foremost. This is actually a great learning project for someone to understand what goes into a Linux system. > If I were developing an embedded project, I don't know about you, but I would suggest focusing on the project itself might be a nice idea, not wasting time on things like a custom OS Using an off the shelf distribution is ideal your goal is rapid prototyping, but most real-world embedded projects end up requiring custom distributions sooner or later. Distributions tailored to interactive use tend not to be so great for distributing and upgrading predictable firmware. You really want all of your devices in a known state, not a random mix of package versions depending on when they last ran ‘apt-get upgrade’, for example. In production-grade products, the OS is often built with tools like Buildroot or OpenEmbedded (Yocto), not from scratch. However, doing a tutorial like this once is a good learning exercise.
- synergy20 5y agoRPI also sells modules for commercial products, so anything you play with RPI can be used on products too.
- johnklos 5y ago
- LeoPanthera 5y agoIt claims there's no supported way to boot from a read-only filesystem with Raspberry Pi OS, but there is. Setting it up is built into raspi-config, at: Performance Options > Overlay File System
- PragmaticPulp 5y agoThis is a great series of tutorials to follow if you want to gain a better understanding of what goes into a basic Linux system. I think some of the commenters here are missing the point that it’s a learning exercise. For production-grade custom Linux firmware, two of the most popular options are Buildroot and OpenEmbedded (Yocto). I’d recommend that anyone interested in this space get started with Buildroot. It’s really easy to make a basic image and customize it to your needs, plus you’ll learn a lot along the way. Yocto is much more powerful and customizable, but the learning curve is far more difficult. It’s great for more advanced situations where you need to support multiple boards or bring in 3rd-party layers.
- codetrotter 5y agoI second that, Buildroot is great
- unmole 5y agoPTXdist is also pretty good and very similar to Buildroot. My experience is a bit dated but PTXdist had better support for some boards than Buildroot.
- montecarl 5y agoI have built several embedded linux distributions for raspberry pi using buildroot. I have had great luck with it. There is a bit of a learning curve, but that seems to be the case with most embedded devices. I would recommend anyone getting started to try it out.
- elcritch 5y agoMy favorite is using Nerves system that uses buildroot and boots directly to Elixir. Buildroot can be a bit of a pain but it’s fun to get a 20 mb Linux image with a few commands.
- TickleSteve 5y agoI would narrow that recommendation to just BuildRoot TBH. It fits much more with the kernel-config style whereas Yocto config seems like its from another planet. BuildRoot is much easier to work with IMO and gives equivalent or better results.
- willjp 5y agoThis is really interesting! Thank you so much!
- sydthrowaway 5y agoThis is interesting. I have always worked with baremetal systems. Are there any good courses for understanding modern Embedded Linux standards who for shops who end up using a COTS dev board?
- stonecharioteer 5y agoDoes anyone who's read this want to weigh in on how it holds up against Linux From Scratch?
- teleforce 5y agoNot on Linux distribution but this Arm sponsored textbook 'Operating Systems Foundations with Linux on the Raspberry Pi' is a useful learning guide: https://www.arm.com/resources/education/books/operating-systems https://www.arm.com/resources/education/books/operating-syst...
- scns 5y agoLooks good, sponsored usually you get it for free though.
- rvz 5y agoRolling your own Embedded Linux on a device like the Pi is all fun and games for hobbyists until you run into the most typical security vulnerabilities and maintenance hell which comes from being unable to update it to the latest firmware. Maybe we will see improvements in this space once other secure alternative operating systems and kernels designed for running on embedded systems are available.
- MrBuddyCasino 5y agoIf I wanted to build a RPi based system that has good support for bluetooth, audio (ALSA) and wifi, with fast boot times, what would be the most sensible route? Alpine or Buildroot? What are the advantages and drawbacks of them?
- mro_name 5y agothis is a remarkably well designed website, thanks for sharing.
- davemtl 5y agoMaybe it's just me, but I get forwarded to an advert for iFastNet and the domain gets forwarded to suspended-website.com.
- leowbattle 5y agoI got that problem too.
- niel 5y agoI suspect the flood of visitors from HN exceeded the hosting account's quota.
- mcshicks 5y agohttps://web.archive.org/web/20210901081906/https://kevinboone.me/pi_minimal.html?i=2 https://web.archive.org/web/20210901081906/https://kevinboon...
- cf100clunk 5y agoLink to kevinboone.me now redirects to suspended-website.com which then cycles through crap links.
- dengolius 5y agoomg link is not work, domain is for sale...