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
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.
-
Plasma Desktop Will Soon Ask for Donations
The next iteration of Plasma has reached the soft feature freeze for the 6.2 version and includes a feature that could be divisive.
-
Linux Market Share Hits New High
For the first time, the Linux market share has reached a new high for desktops, and the trend looks like it will continue.
-
LibreOffice 24.8 Delivers New Features
LibreOffice is often considered the de facto standard office suite for the Linux operating system.
-
Deepin 23 Offers Wayland Support and New AI Tool
Deepin has been considered one of the most beautiful desktop operating systems for a long time and the arrival of version 23 has bolstered that reputation.
-
CachyOS Adds Support for System76's COSMIC Desktop
The August 2024 release of CachyOS includes support for the COSMIC desktop as well as some important bits for video.
-
Linux Foundation Adopts OMI to Foster Ethical LLMs
The Open Model Initiative hopes to create community LLMs that rival proprietary models but avoid restrictive licensing that limits usage.
-
Ubuntu 24.10 to Include the Latest Linux Kernel
Ubuntu users have grown accustomed to their favorite distribution shipping with a kernel that's not quite as up-to-date as other distros but that changes with 24.10.
-
Plasma Desktop 6.1.4 Release Includes Improvements and Bug Fixes
The latest release from the KDE team improves the KWin window and composite managers and plenty of fixes.
-
Manjaro Team Tests Immutable Version of its Arch-Based Distribution
If you're a fan of immutable operating systems, you'll be thrilled to know that the Manjaro team is working on an immutable spin that is now available for testing.