Build a minimal Raspberry Pi OS from source
Linux Emerges
During the download, you specified the kernel version but not the variant that matches the hardware. Raspberry Pi models belong to three hardware categories. At the lower end are the Raspberry Pi 1, the Pi Zero variants, and Compute Module 1 (CM1). At the upper end are the Raspberry Pi 4 and 400. In between are the Raspberry Pi 2 and 3 and CM3.
The next script creates the kernel and the base system:
$ export target=pi2 $ ./2_basesystem.sh |& tee 2_basesystem.log
The first line provides the correct mapping. Depending on the variant, the script generates its own kernel image (kernel.img
, kernel7.img
, and kernel8.img
) and corresponding modules. If the variable is missing, the script generates a kernel for the Raspberry Pi 2/3/CM3 hardware group.
If you set the branch with a variable at download time as described above, then the script completes without any further interaction and creates a kernel with the default configuration. However, if you copy a .config
file to the detLFS directory, the script calls make oldconfig
. Because the sources are usually more recent than when the kernel configuration and some drivers were added; you need to answer a handful of questions. The simplest (and usually most sensible) variant is to accept the default value by pressing Enter.
For full control of the kernel configuration, set the MENUCONFIG
variable. The value does not matter, the main thing is that the variable is not empty. In this case, the script calls make menuconfig
, after which the kernel can be customized to your liking.
People who go to the trouble of making their own kernel often also change the boot logo. To do this, copy an image to the logo/
folder in the root directory of the project. The name must be mylogo.<xxx>
; for a common JPEG file, this would be mylogo.jpg
. If the convert
tool from the ImageMagick package and the tools from the Netpbm package are on the system, the call in the last script converts the logo to the format expected by the kernel.
On the Card
After running the script to create the base system, all the files reside in the Destination/
folder. The original project copies the files directly to an SD card with the 4_mksdcard.sh
script. Alternatively, 4_mkimg.sh
creates an image file that differs from the usual Raspberry Pi images in terms of size and content only. You can then transfer these to an SD card with the usual tools. Both scripts need root privileges, so you will have to run them with sudo
.
If you use the original 4_mksdcard.sh
script, you have to enter the correct device name of your SD card reader beforehand into the script with an editor and remove the premature abort built in for safety.
After this step comes the moment of truth. If successful, the system boots with your own logo (Figure 4). On the first and second consoles, which you select with Alt+F1 and Alt+F2, respectively, a login for the root user with password root appears.
First Boot
When you boot, the fast startup process is immediately noticeable: After the kernel hands over control to /sbin/init
, not much happens. The SysVinit system starts the few processes from /etc/inittab
; besides the two consoles mentioned earlier, these processes include the /etc/rcS
script, which just prints a hello world message.
At this point, you could have a control program that takes control of the Raspberry Pi's GPIOs, for example. The original project also includes a script that can be used to send a few additional packets to the Pi and turn the system into a WiFi repeater. Essentially, the LFS system provides only an extremely minimal basis on which you can build your own projects.
Thanks to the multifunction binary BusyBox software suite, the system comes up with a number of programs that have all the basic functions of the standard programs but do without all the options to save space. Although it was no problem to configure the Pi's Ethernet interface and open a connection to the Internet, I had to look up the commands and syntax in my cheat sheets from more than 20 years ago. The usual distributions offer the luxury of simple configuration files.
« Previous 1 2 3 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.