Linux From Scratch

Last updated

Linux From Scratch
Developer Gerard Beekmans et al.
OS family Unix-like
Working stateCurrent
Source model Open source
Initial releaseDecember 1999;24 years ago (1999-12)
Latest release 12.2 / 1 September 2024 [1] [2]
Update methodSource-based
Package manager None (source-based)
Platforms IA-32, x86-64 [3]
Kernel type Monolithic
Default
user interface
CLI
License Creative Commons licenses Mainly CC BY-NC-SA [4] and MIT License
Official website www.linuxfromscratch.org

Linux From Scratch (LFS) is a type of a Linux installation and the name of a book written by Gerard Beekmans, and as of May 2021, mainly maintained by Bruce Dubbs. The book gives readers instructions on how to build a Linux system from source. The book is available freely from the Linux From Scratch site. [1]

Contents

Projects under LFS

Linux From Scratch is a way to install a working Linux system by building all components of it manually. This is, naturally, a longer process than installing a pre-compiled Linux distribution. According to the Linux From Scratch site, the advantages to this method are a compact, flexible and secure system and a greater understanding of the internal workings of the Linux-based operating systems. [5]

To keep LFS small and focused, the book Beyond Linux From Scratch (BLFS) was created, which presents instructions on how to further develop the basic Linux system that was created in LFS. It introduces and guides the reader through additions to the system including the X Window System, desktop environments (KDE, GNOME, Xfce, LXDE), productivity software, web browsers, programming languages and tools, multimedia software, and network management and system administration tools. Since Release 5.0, the BLFS book version matches the LFS book version. [6]

The book Cross Linux From Scratch (CLFS) focuses on cross compiling, including compiling for headless or embedded systems that can run Linux, but lack the resources needed to compile Linux. CLFS supports a broad range of processors and addresses advanced techniques not included in the LFS book such as cross-build toolchains, multilibrary support (32 & 64-bit libraries side-by-side), and alternative instruction set architectures such as Itanium, SPARC, MIPS, and Alpha.

The Linux from Scratch project, like BitBake, also supports cross-compiling Linux for ARM embedded systems such as the Raspberry Pi and BeagleBone. [7] [8]

The book Hardened Linux From Scratch (HLFS) focuses on security enhancements such as hardened kernel patches, mandatory access control policies, stack-smashing protection, and address space layout randomization. Besides its main purpose of creating a security-focused operating system, HLFS had the secondary goal of being a security teaching tool. It has not been updated since 2011.

Automated Linux From Scratch (ALFS) is a project designed to automate the process of creating an LFS system. It is aimed at users who have gone through the LFS and BLFS books several times and wish to reduce the amount of work involved. A secondary goal is to act as a test of the LFS and BLFS books by directly extracting and running instructions from the XML sources of the LFS and BLFS books.

Requirements and procedure

A clean partition and a working Linux system with a compiler and some essential software libraries are required to build LFS. Instead of installing from an existing Linux system, one can also use a Live CD to build an LFS system.

The project formerly maintained the Linux From Scratch Live CD. [9] LFS Live CD contains all the source packages (in the full version of the Live CD only), the LFS book, automated building tools and (except for the minimal Live CD version) an Xfce GUI environment to work in. The official LFS Live CD is no longer maintained, and cannot be used to build the LFS version7 or later. [9] There are, however, two unofficial builds that can be used to build a 32-bit or 64-bit kernel and userspace respectively for LFS 7.x. [10]

First, a toolchain must be compiled consisting of the tools used to compile LFS, like GCC, glibc, binutils, and other necessary utilities. Then, the root directory must be changed, (using chroot), to the toolchain's partition to start building the final system. One of the first packages to compile is glibc; after that, the toolchain's linker must be adjusted to link against the newly built glibc, so that all other packages that will make up the finished system can be linked against it as well. During the chroot phase, bash's hashing feature is turned off and the temporary toolchain's bin directory moved to the end of PATH. This way the newly compiled programs come first in PATH and the new system builds on its own new components.

List of packages in LFS

ComponentDescriptionLicense
Acl An access control list (ACL), with respect to a computer file system, is a list of permissions attached to an object. GNU GPL
AttrCommands for Manipulating Filesystem Extended Attributes. GNU GPL
Autoconf Tool for producing configure scripts for C, C++, Fortran, Fortran 77, Erlang, Objective-C software on Unix-like computer systems. GNU GPL
Automake A programming tool that produces portable makefiles for use by the make program, used in compiling software. GNU GPL
Bash A free software Unix shell written for the GNU Project GNU GPL
bc bc is a basic calculator (often referred to as bench calculator), is "an arbitrary precision calculator language" with syntax similar to the C programming language. GNU GPL
Binutils A collection of programming tools for the manipulation of object code in various object file formats. GNU GPL
Bison A parser generator that is part of the GNU Project. Bison converts a grammar description for a context-free grammar into source code for a C, C++ or Java parser. GNU GPL
Bzip2 A free and open source lossless data compression algorithm and program developed by Julian Seward. BSD-like License
Check A unit testing framework for C. GNU GPL
Coreutils A package of GNU software containing many of the basic tools, such as cat, ls, and rm, needed for Unix-like operating systems. GNU GPL
DejaGNU A framework for testing other programs. It has a main script called runtest that goes through a directory looking at configuration files and then runs some tests with given criteria. GNU GPL
Diffutils A data comparison utility that outputs the differences between two files. GNU GPL
E2fsprogs e2fsprogs (sometimes called the e2fs programs) is a set of utilities for maintaining the ext2, ext3 and ext4 file systems. GNU GPL
Elfutils A collection of utilities and libraries to read, create and modify ELF binary files. GNU GPL and GNU LGPL
Eudev A fork of udev in order to avoid dependency on the systemd architecture. The resulting fork is called eudev and it makes udev functionality available without systemd. GNU GPL
Expat A stream-oriented XML 1.0 parser library, written in C. MIT License
Expect Expect is a Unix automation and testing tool as an extension to the Tcl scripting language, for interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, ssh, and others. Public domain
File file command is a standard Unix program for recognizing the type of data contained in a computer file. BSD-like License
Findutils The GNU Find Utilities are the basic directory searching utilities of the GNU operating system. GNU GPL
Flex flex (fast lexical analyzer generator) is a free software alternative to lex. BSD license
Gawk Gawk is a programming language that is designed for processing text-based data, either in files or data streams GNU GPL
GCC The GNU Compiler Collection (usually shortened to GCC) is a compiler system produced by the GNU Project supporting various programming languages
GDBM GDBM simple database engines
Gettext Gettext is the GNU internationalization and localization (i18n) library.
Glibc The GNU C Library, commonly known as glibc, is the C standard library released by the GNU Project.
GMP The GNU Multiple-Precision Library, also known as GMP, is a free library for arbitrary-precision arithmetic, operating on signed integers, rational numbers, and floating point numbers.
GperfA perfect hash function generator. For a given list of strings, it produces a hash function and hash table, in form of C or C++ code, for looking up a value depending on the input string. The hash function is perfect, which means that the hash table has no collisions, and the hash table lookup needs a single string comparison only.
Grep grep is a command line text search utility originally written for Unix.
Groff Groff is the GNU replacement for the troff and nroff text formatters.
GRUB GNU GRUB (short for GNU GRand Unified Bootloader) is a boot loader package from the GNU Project.
Gzip Gzip is a software application used for file compression. gzip is short for GNU zip
iana-etc.iana-etc. installs services and protocols using data from the Internet Assigned Numbers Authority. Included are snapshots of the data from the IANA, scripts to transform that data into the needed formats, and scripts to fetch the latest data. Open Software License
Inetutils A collection of network tools, including: telnet, ftp, and rsh. GNU GPL
IntltoolA set of tools to centralize translation of many different file formats using GNU gettext-compatible PO files.
IPRoute2 A collection of userspace utilities for controlling and monitoring various aspects of networking in the Linux kernel, including routing, network interfaces, tunnels, traffic control, and network-related device drivers.
KbdA package contains tools for managing the Linux console (Linux console, virtual terminals on it, keyboard, etc.). Mainly, what they do is loading console fonts and keyboard maps. Also this package contains a set of various fonts and keyboard maps.
Kmod A multi-call binary which implements the programs used to control Linux Kernel modules.
less less is a terminal pager program on Unix, Windows and Unix-like systems used to view (but not change) the contents of a text file one screen at a time.Dual: either GPL or BSD-like License
LFS-BootscriptsThe LFS-Bootscripts package contains a set of scripts to start/stop the LFS system at bootup/shutdown. The configuration files and procedures needed to customize the boot process are described in the following sections. Creative Commons licenses and MIT License
LibcapAn alternative to the superuser model of privilege under Linux.
Libffi A Portable Foreign Function Interface Library. MIT License
LibpipelineLibpipeline is a C library for manipulating pipelines of subprocesses in a flexible and convenient way. GNU GPL
Libtool GNU Libtool is a GNU programming tool from the GNU build system used for creating portable compiled libraries.
Linux The Linux kernel is an operating system kernel used by the Linux family of Unix-like operating systems.
GNU m4 GNU m4 is the GNU version of the m4 macro preprocessor.
make Make is a utility for automatically building executable programs and libraries from source code.
Man-DBMan-DB is an implementation of the standard Unix documentation system accessed using the man command. It uses a Berkeley DB database in place of the traditional flat-text whatis databases.
Man-pages A man page (short for manual page) is a form of online software documentation usually found on a Unix or Unix-like operating system.Multiple Licenses. [11]
Meson an open source build system meant to be both extremely fast, and, even more importantly, as user friendly as possible. Apache License
MPCA C library for the arithmetic of complex numbers with arbitrarily high precision GNU LGPL
MPFR GNU C library for multiple-precision floating-point computations with correct rounding. GNU LGPL and GNU GPL for special exception part of the source code
ncurses A programming library for writing text user interfaces in a terminal-independent manner X11 License [12]
Ninja A small build system with a focus on speed. Apache License
OpenSSL A software library for applications that provide secure communications over computer networks against eavesdropping, and identify the party at the other end. It is widely used by Internet servers, including the majority of HTTPS websites. Apache License  1.0 and four-clause BSD License
Patch A computer tool for Unix programs that updates text files according to instructions contained in a separate file, called a patch file. GNU GPL
Perl A dynamic interpreted programming language Artistic License 1.0 [13] [14] or GNU GPL [15]
Pkg-config A computer program that provides a unified interface for querying installed libraries for the purpose of compiling software from its source code. GNU GPL
ProcpsA set of command line and full-screen utilities that provide information out of the pseudo-filesystem most commonly located at /proc. This filesystem provides a simple interface to the kernel data structures. The programs of procps generally concentrate on the structures that describe the processes running on the system. GNU GPL and GNU LGPL
PsmiscA set of some small useful utilities that use the proc filesystem. GNU GPL
Python An open source interpreted high-level programming language for general-purpose programming Python Software Foundation License
Python DocumentationPackage contains the Python development environment.
Readline GNU readline is a software library created and maintained by the GNU Project. GNU GPL
sed sed (stream editor) is a Unix utility that (a) parses text files and (b) implements a programming language which can apply textual transformations to such files.
Shadow A tool on most Unix and Unix-like operating systems used to change a user's password. The password entered by the user is run through a key derivation function to create a hashed version of the new password, which is saved. Only the hashed version is stored; the entered password is not saved for security reasons. Artistic License or BSD-like License
SysklogdA Kernel and system logging daemons that provides two system utilities which provide support for system logging and kernel message trapping. Support of both internet and unix domain sockets enables this utility package to support both local and remote logging. GNU GPL
Sysvinit System V style init programs that control the booting and shutdown system.
tar tar is a program that provides the ability to create tar archives, as well as various other kinds of manipulation.
Tcl Tool Command Language is a dynamic scripting language. BSD-like License [16]
Texinfo A typesetting syntax used for generating documentation in both on-line also printed form and the official documentation format of the GNU project. GNU GPL
tzdata The public-domain time zone database contains code and data that represent the history of local time for many representative locations around the globe. Public domain and BSD
Udev Configuration TarballThe Udev package contains programs for dynamic creation of device nodes. The development of udev has been merged with systemd, but most of systemd is incompatible with LFS. Here we build and install just the needed udev files. Creative Commons licenses and MIT License
util-linux The Util-linux package contains miscellaneous utility programs. Among them are utilities for handling file systems, consoles, partitions, and messages. GNU GPL
Vim language files (recommended)A text editor built to create and change any kind of text. Free software (Vim License), charityware
Wheel This library is the reference implementation of the Python wheel packaging standard, as defined in PEP 427. MIT
XML::Parser
XZ Utils A general-purpose data compression software with a high compression ratio. XZ Utils were written for POSIX-like systems, but also work on some not-so-POSIX systems. XZ Utils are the successor to LZMA Utils. GNU GPL and GNU LGPL
Zlib Zlib is a software library used for data compression. zlib license
zstd zstd a fast lossless compression algorithm and data compression tool. Compress or decompress .zst files.BSD + GPLv2 dual license. [17]

[18] This is a list of the packages included in CLFS version 1.1.0. Unless otherwise noted, this list is applicable to all supported architectures.

Standard build unit

A "standard build unit" ("SBU") is a term used during initial bootstrapping of the system, and represents the amount of time required to build the first package in LFS on a given computer. Its creation was prompted by the long time required to build an LFS system, and the desire of many users to know how long a source tarball will take to build ahead of time.

As of Linux From Scratch version 10.1, the first package built by the user is GNU binutils. When building it, users are encouraged to measure the build process using shell constructs and dub that time the system's "standard build unit". Once this number is known, an estimate of the time required to build later packages is expressed relative to the known SBU.

Several packages built during compilation take much longer to build than binutils, including the GNU C Library (rated at 4.2 SBUs) and the GNU Compiler Collection (rated at 11 SBUs). The unit must be interpreted as an approximation; various factors influence the actual time required to build a package.

Reception

LWN.net reviewed LFS in 2004: [19]

Linux From Scratch is a wonderful project. It should become a compulsory reading material for all Linux training courses, and something that every Linux enthusiast should complete at least once. This would also create another interesting side effect: people who tend to be quick in expressing dissatisfaction on the distributions' mailing lists and forums would probably show a lot more respect for the developers. Installing a ready-made distribution is a trivial task. Building up a set of 4 CDs containing a stable, secure and reliable operating system, plus thousands of applications, is most definitely not.

Tux Machines wrote a review about Linux From Scratch 6.1 in 2005: [20]

Now on to BLFS. Unfortunately Beyond Linux From Scratch is always a book behind it seems. To me it's not a real install until one can log into a window manager.

Tux Machines also has a second [21] and a third part [22] of the review.

See also

Other source-based Linux distributions:

Related Research Articles

<span class="mw-page-title-main">Linux distribution</span> Operating system based on the Linux kernel

A Linux distribution is an operating system made from a software collection that includes the Linux kernel and often a package management system. They are often obtained from the website of each distribution, which are available for a wide variety of systems ranging from embedded devices and personal computers to servers and powerful supercomputers.

<span class="mw-page-title-main">Mandriva Linux</span> Linux distribution

Mandriva Linux is a discontinued Linux distribution developed by Mandriva S.A.

<span class="mw-page-title-main">Source Mage</span> Linux distribution

Source Mage is a source-based Linux distribution descended from Sorcerer. Components of this operating system are downloaded as source code and compiled locally on the user's computer.

<span class="mw-page-title-main">Syllable Desktop</span> Operating system

Syllable Desktop is a discontinued free and open-source lightweight hobbyist operating system for Pentium and compatible processors. Its purpose was to create an easy-to-use desktop operating system for the home and small office user. It was forked and expanded AtheOS after the developer of AtheOS moved on to other projects in July 2002.

<span class="mw-page-title-main">Gentoo Linux</span> Linux distribution

Gentoo Linux is a Linux distribution built using the Portage package management system. Unlike a binary software distribution, the source code is compiled locally according to the user's preferences and is often optimized for the specific type of computer. Precompiled binaries are available for some packages. Gentoo runs on a wide variety of processor architectures.

A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. For example, a compiler that runs on a PC but generates code that runs on Android devices is a cross compiler.

The GNU C Library, commonly known as glibc, is the GNU Project implementation of the C standard library. It is a wrapper around the system calls of the Linux kernel for application use. Despite its name, it now also directly supports C++. It was started in the 1980s by the Free Software Foundation (FSF) for the GNU operating system.

<span class="mw-page-title-main">MinGW</span> Free and open-source software for developing applications in Microsoft Windows

MinGW, formerly mingw32, is a free and open source software development environment to create Microsoft Windows applications.

The GNU toolchain is a broad collection of programming tools produced by the GNU Project. These tools form a toolchain used for developing software applications and operating systems.

<span class="mw-page-title-main">Arch Linux</span> Rolling release distribution of Linux

Arch Linux is an independently developed x86-64 general-purpose Linux distribution that strives to provide the latest stable versions of most software by following a rolling-release model. The default installation is intentionally minimal so that users can add only the packages they require.

This is a list of operating systems specifically focused on security. Similar concepts include security-evaluated operating systems that have achieved certification from an auditing organization, and trusted operating systems that provide sufficient support for multilevel security and evidence of correctness to meet a particular set of requirements.

<span class="mw-page-title-main">Sabayon Linux</span> Gentoo-based Linux distribution

Sabayon Linux or Sabayon, was an Italian Gentoo-based Linux distribution created by Fabio Erculiani and the Sabayon development team. Sabayon followed the "out of the box" philosophy, aiming to give the user a wide number of applications ready to use and a self-configured operating system.

<span class="mw-page-title-main">CMake</span> Cross-platform, compiler-independent build system generator

In software development, CMake is cross-platform free and open-source software for build automation, testing, packaging and installation of software by using a compiler-independent method. CMake is not a build system itself; it generates another system's build files. It supports directory hierarchies and applications that depend on multiple libraries. It can invoke native build environments such as Make, Qt Creator, Ninja, Android Studio, Apple's Xcode, and Microsoft Visual Studio. It has minimal dependencies, requiring only a C++ compiler on its own build system.

<span class="mw-page-title-main">Linux</span> Family of Unix-like operating systems

Linux is a generic name for a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution (distro), which includes the kernel and supporting system software and libraries, many of which are provided by the GNU Project.

gold (linker)

In software engineering, gold is a linker for ELF files. It became an official GNU package and was added to binutils in March 2008 and first released in binutils version 2.19. gold was developed by Ian Lance Taylor and a small team at Google. The motivation for writing gold was to make a linker that is faster than the GNU linker, especially for large applications coded in C++.

Alpine Linux is a Linux distribution designed to be small, simple, and secure. It uses musl, BusyBox, and OpenRC instead of the more commonly used glibc, GNU Core Utilities, and systemd. This makes Alpine one of few Linux distributions not to be based on the GNU Core Utilities.

<span class="mw-page-title-main">Platypux</span> Linux distribution

Platypux was a French Linux distribution of the Slackware family, developed by Pierre-Aimé and Jacques-Olivier.

<span class="mw-page-title-main">Buildroot</span>

Buildroot is a set of Makefiles and patches that simplifies and automates the process of building a complete and bootable Linux environment for an embedded system, while using cross-compilation to allow building for multiple target platforms on a single Linux-based development system. Buildroot can automatically build the required cross-compilation toolchain, create a root file system, compile a Linux kernel image, and generate a boot loader for the targeted embedded system, or it can perform any independent combination of these steps. For example, an already installed cross-compilation toolchain can be used independently, while Buildroot only creates the root file system.

References

  1. 1 2 "LFS News". www.linuxfromscratch.org. Retrieved 2 September 2023.
  2. Beekmans, Gerard (2023). Linux From Scratch, Version 12.0 (PDF).
  3. Preface:LFS Target Architectures, Linux From Scratch
  4. "Appendix D. LFS Licenses" . Retrieved 9 August 2023.
  5. What is Linux From Scratch?, LFS Project Homepage
  6. Gerard Beekmans: Beyond Linux From Scratch, Version 6.3 (August 2008)
  7. "Cross-Compiled Linux From Scratch - Embedded".
  8. Brendan Horan. "Practical Raspberry Pi". 2013. p. 105.
  9. 1 2 "LFS LiveCD Project Homepage". www.linuxfromscratch.org. Retrieved 25 May 2018.
  10. "Index of /~kb0iic/livecdupd". clfs.org. Retrieved 25 May 2018.
  11. "Licenses for manual pages". www.kernel.org. Retrieved 25 May 2018.
  12. "NCURSES – Licensing" . Retrieved 9 July 2013.
  13. "The "Artistic License" - dev.perl.org". dev.perl.org. Retrieved 25 May 2018.
  14. Artistic - file on the Perl 5 git repository
  15. "Perl Licensing". dev.perl.org. Retrieved 8 January 2011.
  16. "Tcl/Tk Licensing Terms" . Retrieved 8 January 2011.
  17. "New license", GitHub "facebook/zstd"
  18. "LIST: /lfs/downloads/stable/wget-list" (txt).
  19. "Learning with Linux From Scratch [LWN.net]". lwn.net. Retrieved 28 March 2020.
  20. "Linux From Scratch 6.1 (part 1?) | Tux Machines". www.tuxmachines.org. Retrieved 28 March 2020.
  21. "Linux From Scratch 6.1 - Part 2 - BLFS | Tux Machines". www.tuxmachines.org. Retrieved 28 March 2020.
  22. "Beyond Beyond Linux from Scratch (lfs - part3) | Tux Machines". www.tuxmachines.org. Retrieved 28 March 2020.