On the DVD
Cross-Compiling
To minimize the influence of the build host's operating system, you need to make sure that the LFS system is independent of it. Chapters 5 and 6 help you create the software tools you'll need to build Linux From Scratch. You then deploy these tools in an isolated chroot environment only for the purpose of building LFS.
The build process is based on the principle of cross-compiling: A cross-compiler is typically used to compile code for other system architectures. On your build machine, a cross-compiler is theoretically not necessary because you are most likely building on x86_64 for x86_64. However, you will want LFS to be free of inlinked software from the build host, which a cross-compiler guarantees.
The LFS documentation assumes you have three hosts, each with a different architecture. Host A has a compiler for its own architecture. The host is slow and its capacity is limited. Host B does not have a compiler initially, but it is fast and well equipped. It will be producing the software for Host C. Host C, with yet another architecture, also has no compiler and is small and slow.
This scenario requires two cross compilers: Cross-Compiler A and Cross-Compiler B. On Host A, the compiler builds Cross-Compiler A, which in turn builds Cross-Compiler B. Cross-Compiler B is used on Host B to build Compiler C and all programs for Host C. However, they cannot be tested on Host B. Therefore, Compiler C rebuilds and tests itself on Host C.
For LFS, you need to use the cross-compiler to compile not only the C compiler but also the glibc and libstdc++ libraries. The problem is that, to be built, the C compiler relies internally on libgcc, which in turn has to be linked against glibc – which doesn't exist yet.
To work around these circular dependencies, first build a minimal version of the cross-compiler build host that is just about good enough to compile a full-fledged glibc, as well as a minimally functional libstdc++. The libstdc++ library will be built again later in the chroot environment, this time completely. See the Toolchain Technical Notes at the beginning of Part III of the LFS book for more on the LFS build environment.
Conclusion
As you wade through the details of the process described in this article, you will quickly see that building Linux From Scratch takes a lot of time, energy, and attention. If you have the time and inquisitiveness, the LFS project will provide you with hands-on practice with building your own distribution. You'll learn about all the necessary components and how they interact with each other. You'll also learn about the build process itself. If you want to, you can use LFS as a starting point for your own development contributions.
At the end of the process, LFS provides you with an up-to-date, working, and very compact Linux system that includes not much more than the kernel and some tools. Building a distribution yourself helps you stay extremely flexible. LFS gives you the shell of a house that you can customize to suit your own taste, from one-room apartment to luxury villa. LFS can be completely audited if required, and, perhaps even more importantly, you have complete control over all security patches. Last but not least: LFS is simply cool.
To dampen expectations a bit: LFS is not especially convenient for a production environment. An SSH daemon is missing, as are sudo, Wget, and Parted. LVM is not available to manage the filesystem, and the network stack is anything but complete. BLFS, which is available at the Linux From Scratch website, helps you implement those features as advanced topics.
Be aware of the fact that you will need to keep your LFS system up-to-date by downloading and compiling security updates on a regular basis. For this, the Linux From Scratch documentation discusses a process for simplifying the package management process and defining a package user [5]. A package manager is not used in the entire LFS project, although it is possible to extend LFS by adding a manager such as Pacman or GNU Stow [6]. Your self-built Linux distribution also lacks features such as an active user community, QA-tested packages including errata, an extensive mirror network, contactable developers, and conveniences such as a wiki, IRC chat, mailing lists, forums, bug trackers, or an FAQ.
With LFS, Linux knowledge is not taught but assumed, so you'll need some background in Linux to get started. But if you're ready to roll up your sleeves and dive in, Linux From Scratch will help you build a deeper understanding of the Linux kernel and open source software.
Infos
- Linux From Scratch: https://www.linuxfromscratch.org/
- Beyond Linux From Scrach: https://www.linuxfromscratch.org/blfs/
- Debian Wiki: https://wiki.debian.org/
- Debian Installation Guide: https://www.debian.org/releases/stable/amd64/index.en.html
- Package user approach: http://www.linuxfromscratch.org/hints/downloads/files/more_control_and_pkg_man.txt
- GNU Stow: https://www.gnu.org/software/stow
« Previous 1 2
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
-
Fedora 43 Has Finally Landed
The Fedora Linux developers have announced their latest release, Fedora 43.
-
KDE Unleashes Plasma 6.5
The Plasma 6.5 desktop environment is now available with new features, improvements, and the usual bug fixes.
-
Xubuntu Site Possibly Hacked
It appears that the Xubuntu site was hacked and briefly served up a malicious ZIP file from its download page.
-
LMDE 7 Now Available
Linux Mint Debian Edition, version 7, has been officially released and is based on upstream Debian.
-
Linux Kernel 6.16 Reaches EOL
Linux kernel 6.16 has reached its end of life, which means you'll need to upgrade to the next stable release, Linux kernel 6.17.
-
Amazon Ditches Android for a Linux-Based OS
Amazon has migrated from Android to the Linux-based Vega OS for its Fire TV.
-
Cairo Dock 3.6 Now Available for More Compositors
If you're a fan of third-party desktop docks, then the latest release of Cairo Dock with Wayland support is for you.
-
System76 Unleashes Pop!_OS 24.04 Beta
System76's first beta of Pop!_OS 24.04 is an impressive feat.
-
Linux Kernel 6.17 is Available
Linus Torvalds has announced that the latest kernel has been released with plenty of core improvements and even more hardware support.
-
Kali Linux 2025.3 Released with New Hacking Tools
If you're a Kali Linux fan, you'll be glad to know that the third release of this famous pen-testing distribution is now available with updates for key components.

