Chapters
Linux From Scratch Version 12.4

Linux From Scratch Version 12.4

Published September 1st, 2025

Created by Gerard Beekmans and Managing Editor: Bruce Dubbs

Copyright © 1999-2025 Gerard Beekmans Copyright © 1999-2025, Gerard Beekmans All rights reserved.

This book is licensed under a Creative Commons License.

Computer instructions may be extracted from the book under the MIT License.

Linux® is a registered trademark of Linus Torvalds.

Forward

My journey to learn and better understand Linux began back in 1998. I had just installed my first Linux distribution and had quickly become intrigued with the whole concept and philosophy behind Linux.

There are always many ways to accomplish a single task. The same can be said about Linux distributions. A great many have existed over the years. Some still exist, some have morphed into something else, yet others have been relegated to our memories. They all do things differently to suit the needs of their target audience. Because so many different ways to accomplish the same end goal exist, I began to realize I no longer had to be limited by any one implementation.

Prior to discovering Linux, we simply put up with issues in other Operating Systems as you had no choice. It was what it was, whether you liked it or not. With Linux, the concept of choice began to emerge. If you didn't like something, you were free, even encouraged, to change it.

I tried a number of distributions and could not decide on any one. They were great systems in their own right. It wasn't a matter of right and wrong anymore. It had become a matter of personal taste. With all that choice available, it became apparent that there would not be a single system that would be perfect for me. So I set out to create my own Linux system that would fully conform to my personal preferences.

To truly make it my own system, I resolved to compile everything from source code instead of using pre-compiled binary packages. This “perfect” Linux system would have the strengths of various systems without their perceived weaknesses. At first, the idea was rather daunting. I remained committed to the idea that such a system could be built.

After sorting through issues such as circular dependencies and compile-time errors, I finally built a custom-built Linux system. It was fully operational and perfectly usable like any of the other Linux systems out there at the time. But it was my own creation. It was very satisfying to have put together such a system myself. The only thing better would have been to create each piece of software myself. This was the next best thing.

As I shared my goals and experiences with other members of the Linux community, it became apparent that there was a sustained interest in these ideas. It quickly became plain that such custom-built Linux systems serve not only to meet user specific requirements, but also serve as an ideal learning opportunity for programmers and system administrators to enhance their (existing) Linux skills. Out of this broadened interest, the Linux From Scratch Project was born.

This Linux From Scratch book is the central core around that project. It provides the background and instructions necessary for you to design and build your own system. While this book provides a template that will result in a correctly working system, you are free to alter the instructions to suit yourself, which is, in part, an important part of this project.

You remain in control; we just lend a helping hand to get you started on your own journey.

I sincerely hope you will have a great time working on your own Linux From Scratch system and enjoy the numerous benefits of having a system that is truly your own.

Gerard Beekmans gerard@linuxfromscratch.org

Audience

There are many reasons why you would want to read this book. One of the questions many people raise is, “why go through all the hassle of manually building a Linux system from scratch when you can just download and install an existing one?”

One important reason for this project's existence is to help you learn how a Linux system works from the inside out.

Building an LFS system helps demonstrate what makes Linux tick, and how things work together and depend on each other. One of the best things this learning experience can provide is the ability to customize a Linux system to suit your own unique needs.

Another key benefit of LFS is that it gives you control of the system without relying on someone else's Linux implementation. With LFS, you are in the driver's seat. You dictate every aspect of your system.

LFS allows you to create very compact Linux systems. With other distributions you are often forced to install a great many programs you neither use nor understand. These programs waste resources. You may argue that with today's hard drives and CPUs, wasted resources are no longer a consideration. Sometimes, however, you are still constrained by the system's size, if nothing else. Think about bootable CDs, USB sticks, and embedded systems. Those are areas where LFS can be beneficial.

Another advantage of a custom built Linux system is security. By compiling the entire system from source code, you are empowered to audit everything and apply all the security patches you want. You don't have to wait for somebody else to compile binary packages that fix a security hole. Unless you examine the patch and implement it yourself, you have no guarantee that the new binary package was built correctly and adequately fixes the problem.

The goal of Linux From Scratch is to build a complete and usable foundation-level system. If you do not wish to build your own Linux system from scratch, you may nevertheless benefit from the information in this book.

There are too many good reasons to build your own LFS system to list them all here. In the end, education is by far the most important reason. As you continue your LFS experience, you will discover the power that information and knowledge can bring.

LFS Target Architectures

The primary target architectures of LFS are the AMD/Intel x86 (32-bit) and x86_64 (64-bit) CPUs. On the other hand, the instructions in this book are also known to work, with some modifications, with the Power PC and ARM CPUs.

To build a system that utilizes one of these alternative CPUs, the main prerequisite, in addition to those on the next page, is an existing Linux system such as an earlier LFS installation, Ubuntu, Red Hat/Fedora, SuSE, or some other distribution that targets that architecture. (Note that a 32-bit distribution can be installed and used as a host system on a 64-bit AMD/Intel computer.) The gain from building on a 64-bit system, as compared to a 32-bit system, is minimal. For example, in a test build of LFS-9.1 on a Core i7-4790 CPU based system, using 4 cores, the following statistics were measured:


Architecture Build Time     Build Size
32-bit       239.9 minutes  3.6 GB
64-bit       233.2 minutes  4.4 GB

As you can see, on the same hardware, the 64-bit build is only 3% faster (and 22% larger) than the 32-bit build. If you plan to use LFS as a LAMP server, or a firewall, a 32-bit CPU may be good enough. On the other hand, several packages in BLFS now need more than 4 GB of RAM to be built and/or to run; if you plan to use LFS as a desktop, the LFS authors recommend building a 64-bit system.

The default 64-bit build that results from LFS is a “pure” 64-bit system. That is, it supports 64-bit executables only.

Building a “multi-lib” system requires compiling many applications twice, once for a 32-bit system and once for a 64- bit system. This is not directly supported in LFS because it would interfere with the educational objective of providing the minimal instructions needed for a basic Linux system. Some of the LFS/BLFS editors maintain a multilib fork of LFS, accessible at https://www.linuxfromscratch.org/~thomas/multilib/index.html. But that's an advanced topic.

Prerequisites

Building an LFS system is not a simple task. It requires a certain level of existing knowledge of Unix system administration in order to resolve problems and correctly execute the commands listed. In particular, as an absolute minimum, you should already know how to use the command line (shell) to copy or move files and directories, list directory and file contents, and change the current directory. It is also expected that you know how to use and install Linux software.

Because the LFS book assumes at least this basic level of skill, the various LFS support forums are unlikely to provide you with much assistance in these areas. You will find that your questions regarding such basic knowledge will likely go unanswered (or you will simply be referred to the LFS essential pre-reading list).

Before building an LFS system, we urge you to read these articles:


This is a comprehensive guide to building and installing “generic” Unix software packages under Linux. Although it was written some time ago, it still provides a good summary of the basic techniques used to build and install software.


This guide provides a good summary of the basic skills and techniques needed to build software from source code.

LFS and Standards

The structure of LFS follows Linux standards as closely as possible. The primary standards are:

The LSB has four separate specifications: Core, Desktop, Languages, and Imaging. Some parts of Core and Desktop specifications are architecture specific. There are also two trial specifications: Gtk3 and Graphics.

LFS attempts to conform to the LSB specifications for the IA32 (32-bit x86) or AMD64 (x86_64) architectures discussed in the previous section.


Note

Many people do not agree with these requirements. The main purpose of the LSB is to ensure that proprietary software can be installed and run on a compliant system. Since LFS is source based, the user has complete control over what packages are desired; you may choose not to install some packages that are specified by the LSB.


While it is possible to create a complete system that will pass the LSB certification tests “from scratch,” this can't be done without many additional packages that are beyond the scope of the LFS book. Installation instructions for some of these additional packages can be found in BLFS.

Packages supplied by LFS needed to satisfy the LSB Requirements


LSB Core: Bash, Bc, Binutils, Coreutils, Diffutils, File, Findutils, Gawk, GCC, Gettext, Glibc, Grep, Gzip, M4, Man-DB, Procps, Psmisc, Sed, Shadow, SysVinit, Tar, Util-linux, Zlib

LSB Desktop: None

LSB Languages: Perl

LSB Imaging: None LSB Gtk3 and

LSB Graphics (Trial Use): None

Packages supplied by BLFS needed to satisfy the LSB Requirements


LSB Core: At, Batch (a part of At), BLFS Bash Startup Files, Cpio, Ed, Fcrontab, LSB-Tools, NSPR, NSS, Linux-PAM, Pax, Sendmail (or Postfix or Exim), Time

LSB Desktop: Alsa, ATK, Cairo, Desktop-file-utils, Freetype, Fontconfig, Gdk-pixbuf, Glib2, GLU, Icon-naming-utils, Libjpeg-turbo, Libxml2, Mesa, Pango, Xdg-utils, Xorg

LSB Languages: Libxml2, Libxslt

LSB Imaging: CUPS, Cups-filters, Ghostscript, SANE LSB Gtk3 and

LSB Graphics (Trial Use): GTK+3

Components not supplied or optionally supplied by LFS or BLFS needed to satisfy the LSB Requirements


LSB Core: install_initd , libcrypt.so.1 (can be provided with optional instructions for the LFS Libxcrypt package), libncurses.so.5 (can be provided with optional instructions for the LFS Ncurses package), libncursesw.so.5 (but libncursesw.so.6 is provided by the LFS Ncurses package)

LSB Desktop: libgdk-x11-2.0.so (but libgdk-3.so is provided by the BLFS GTK+-3 package), libgtk-x11-2.0.so (but libgtk-3.so and libgtk-4.so are provided by the BLFS GTK+-3 and GTK-4 packages), libpng12.so (but libpng16.so is provided by the BLFS Libpng package), libQt*.so.4 (but libQt6*.so.6 are provided by the BLFS Qt6 package), libtiff.so.4 (but libtiff.so.6 is provided by the BLFS Libtiff package)
LSB Languages: /usr/bin/python (LSB requires Python2 but LFS and BLFS only provide Python3)

LSB Imaging: None

LSB Gtk3 and LSB Graphics (Trial Use): libpng15.so (but libpng16.so is provided by the BLFS Libpng package)

Rationale for Packages in the Book

The goal of LFS is to build a complete and usable foundation-level system—including all the packages needed to replicate itself—and providing a relatively minimal base from which to customize a more complete system based on the user's choices. This does not mean that LFS is the smallest system possible. Several important packages are included that are not, strictly speaking, required. The list below documents the reasons each package in the book has been included.

  • Acl xi

This package contains utilities to administer Access Control Lists, which are used to define fine-grained discretionary access rights for files and directories.

  • Attr

This package contains programs for managing extended attributes on file system objects.

  • Autoconf

This package supplies programs for producing shell scripts that can automatically configure source code from a developer's template. It is often needed to rebuild a package after the build procedure has been updated.

  • Automake

This package contains programs for generating Make files from a template. It is often needed to rebuild a package after the build procedure has been updated.

  • Bash

This package satisfies an LSB core requirement to provide a Bourne Shell interface to the system. It was chosen over other shell packages because of its common usage and extensive capabilities.

  • Bc

This package provides an arbitrary precision numeric processing language. It satisfies a requirement for building the Linux kernel.

  • Binutils

This package supplies a linker, an assembler, and other tools for handling object files. The programs in this package are needed to compile most of the packages in an LFS system.

  • Bison

This package contains the GNU version of yacc (Yet Another Compiler Compiler) needed to build several of the LFS programs.

  • Bzip2

This package contains programs for compressing and decompressing files. It is required to decompress many LFS packages.

  • Check

This package provides a test harness for other programs.

  • Coreutils

This package contains a number of essential programs for viewing and manipulating files and directories. These programs are needed for command line file management, and are necessary for the installation procedures of every package in LFS.

  • DejaGNU

This package supplies a framework for testing other programs.

  • Diffutils

This package contains programs that show the differences between files or directories. These programs can be used to create patches, and are also used in many packages' build procedures.

  • E2fsprogs xii

This package supplies utilities for handling the ext2, ext3 and ext4 file systems. These are the most common and thoroughly tested file systems that Linux supports.

  • Expat

This package yields a relatively small XML parsing library. It is required by the XML::Parser Perl module.

  • Expect

This package contains a program for carrying out scripted dialogues with other interactive programs. It is commonly used for testing other packages.

  • File

This package contains a utility for determining the type of a given file or files. A few packages need it in their build scripts.

  • Findutils

This package provides programs to find files in a file system. It is used in many packages' build scripts.

  • Flex

This package contains a utility for generating programs that recognize patterns in text. It is the GNU version of the lex (lexical analyzer) program. It is required to build several LFS packages.

  • Gawk

This package supplies programs for manipulating text files. It is the GNU version of awk (Aho-Weinberg- Kernighan). It is used in many other packages' build scripts.

  • GCC

This is the Gnu Compiler Collection. It contains the C and C++ compilers as well as several others not built by LFS.

  • GDBM

This package contains the GNU Database Manager library. It is used by one other LFS package, Man-DB.

  • Gettext

This package provides utilities and libraries for the internationalization and localization of many packages.

  • Glibc

This package contains the main C library. Linux programs will not run without it.

  • GMP

This package supplies math libraries that provide useful functions for arbitrary precision arithmetic. It is needed to build GCC.

  • Gperf

This package produces a program that generates a perfect hash function from a set of keys. It is required by Udev .

  • Grep

This package contains programs for searching through files. These programs are used by most packages' build scripts.

  • Groff xiii

This package contributes programs for processing and formatting text. One important function of these programs is to format man pages.

  • GRUB

This is the Grand Unified Boot Loader. It is the most flexible of several boot loaders available.

  • Gzip

This package contains programs for compressing and decompressing files. It is needed to decompress many packages in LFS.

  • Iana-etc

This package provides data for network services and protocols. It is needed to enable proper networking capabilities.

  • Inetutils

This package supplies programs for basic network administration.

  • Intltool

This package contributes tools for extracting translatable strings from source files.

  • IProute2

This package contains programs for basic and advanced IPv4 and IPv6 networking. It was chosen over the other common network tools package (net-tools) for its IPv6 capabilities.

  • Kbd

This package produces key-table files, keyboard utilities for non-US keyboards, and a number of console fonts.

  • Kmod

This package supplies programs needed to administer Linux kernel modules.

  • Less

This package contains a very nice text file viewer that allows scrolling up or down when viewing a file. Many packages use it for paging the output.

  • Libcap

This package implements the userspace interfaces to the POSIX 1003.1e capabilities available in Linux kernels.

  • Libelf

The elfutils project provides libraries and tools for ELF files and DWARF data. Most utilities in this package are available in other packages, but the library is needed to build the Linux kernel using the default (and most efficient) configuration.

  • Libffi

This package implements a portable, high level programming interface to various calling conventions. Some programs may not know at the time of compilation what arguments are to be passed to a function. For instance, an interpreter may be told at run-time about the number and types of arguments used to call a given function. Libffi can be used in such programs to provide a bridge from the interpreter program to compiled code.

  • Libpipeline xiv

The Libpipeline package supplies a library for manipulating pipelines of subprocesses in a flexible and convenient way. It is required by the Man-DB package.

  • Libtool

This package contains the GNU generic library support script. It wraps the complexity of using shared libraries into a consistent, portable interface. It is needed by the test suites in other LFS packages.

  • Libxcrypt

This package provides the libcrypt library needed by various packages (notably, Shadow) for hashing passwords.

It replaces the obsolete libcrypt implementation in Glibc.

  • Linux Kernel

This package is the Operating System. It is the Linux in the GNU/Linux environment.

  • M4

This package provides a general text macro processor useful as a build tool for other programs.

  • Make

This package contains a program for directing the building of packages. It is required by almost every package in LFS.

  • Man-DB

This package contains programs for finding and viewing man pages. It was chosen instead of the man package because of its superior internationalization capabilities. It supplies the man program.

  • Man-pages

This package provides the actual contents of the basic Linux man pages.

  • Meson

This package provides a software tool for automating the building of software. The main goal of Meson is to minimize the amount of time that software developers need to spend configuring a build system. It's required to build Systemd, as well as many BLFS packages.

  • MPC

This package supplies arithmetic functions for complex numbers. It is required by GCC.

  • MPFR

This package contains functions for multiple precision arithmetic. It is required by GCC.

  • Ninja

This package furnishes a small build system with a focus on speed. It is designed to have its input files generated by a higher-level build system, and to run builds as fast as possible. This package is required by Meson.

  • Ncurses

This package contains libraries for terminal-independent handling of character screens. It is often used to provide cursor control for a menuing system. It is needed by a number of the packages in LFS.

  • Openssl

This package provides management tools and libraries relating to cryptography. These supply cryptographic functions to other packages, including the Linux kernel.

  • Patch

This package contains a program for modifying or creating files by applying a patch file typically created by the diff program. It is needed by the build procedure for several LFS packages.

  • Perl

This package is an interpreter for the runtime language PERL. It is needed for the installation and test suites of several LFS packages.

  • Pkgconf

This package contains a program which helps to configure compiler and linker flags for development libraries.

The program can be used as a drop-in replacement of pkg-config , which is needed by the building system of many packages. It's maintained more actively and slightly faster than the original Pkg-config package.

  • Procps-NG

This package contains programs for monitoring processes. These programs are useful for system administration, and are also used by the LFS Bootscripts.

  • Psmisc

This package produces programs for displaying information about running processes. These programs are useful for system administration.

  • Python 3

This package provides an interpreted language that has a design philosophy emphasizing code readability.

  • Readline

This package is a set of libraries that offer command-line editing and history capabilities. It is used by Bash.

  • Sed

This package allows editing of text without opening it in a text editor. It is also needed by many LFS packages' configure scripts.

  • Shadow

This package contains programs for handling passwords securely.

  • Sysklogd

This package supplies programs for logging system messages, such as those emitted by the kernel or daemon processes when unusual events occur.

  • SysVinit

This package provides the init program, the parent of all the other processes on a running Linux system.

  • Udev

This package is a device manager. It dynamically controls the ownership, permissions, names, and symbolic links of device nodes in the /dev directory when devices are added to or removed from the system.

  • Tar

This package provides archiving and extraction capabilities of virtually all the packages used in LFS.

  • Tcl xvi

This package contains the Tool Command Language used in many test suites.

  • Texinfo

This package supplies programs for reading, writing, and converting info pages. It is used in the installation procedures of many LFS packages.

  • Util-linux

This package contains miscellaneous utility programs. Among them are utilities for handling file systems, consoles, partitions, and messages.

  • Vim

This package provides an editor. It was chosen because of its compatibility with the classic vi editor and its huge number of powerful capabilities. An editor is a very personal choice for many users. Any other editor can be substituted, if you wish.

  • Wheel

This package supplies a Python module that is the reference implementation of the Python wheel packaging standard.

  • XML::Parser

This package is a Perl module that interfaces with Expat.

  • XZ Utils

This package contains programs for compressing and decompressing files. It provides the highest compression generally available and is useful for decompressing packages in XZ or LZMA format.

  • Zlib

This package contains compression and decompression routines used by some programs.

  • Zstd

This package supplies compression and decompression routines used by some programs. It provides high compression ratios and a very wide range of compression / speed trade-offs.

Typography

To make things easier to follow, there are a few typographical conventions used throughout this book. This section contains some examples of the typographical format found throughout Linux From Scratch.

"./configure --prefix=/usr"

This form of text is designed to be typed exactly as seen unless otherwise noted in the surrounding text. It is also used in the explanation sections to identify which of the commands is being referenced. The copy icon will copy the exact text in double quotes to the copy / paste buffer of your operating system

In some cases, a logical line is extended to two or more physical lines with a backslash at the end of the line.

CC="gcc -B/usr/bin/" ../binutils-2.18/configure \
--prefix=/tools --disable-nls --disable-werror

Note that the backslash must be followed by an immediate return. Other whitespace characters like spaces or tab characters will create incorrect results. - Note on this website use of the copy buttons in code and codeblocks should correctly copy the code into your copy / paste buffer, for critical commands it is always worth pasting to a notepad to be certain.

install-info: unknown option '--dir-file=/mnt/lfs/usr/info/dir'

This form of text (fixed-width text) shows screen output, usually as the result of commands issued. If you are reading the book in the HTML format (instead of PDF), the text should be blue.

The fixed-width text is also used to show filenames, such as /etc/ld.so.conf .

Note

Please configure your browser to display fixed-width text with a good monospace, with which you can distinguish the glyphs of Il1 or O0 clearly.

Emphasis

This form of text is used for several purposes in the book. Its main purpose is to emphasize important points or items.

https://www.linuxfromscratch.org

This format is used for hyperlinks both within the LFS community and to external pages. It includes HOWTOs, download locations, and websites.


cat > $LFS/etc/group << "EOF"
root:x:0:
bin:x:1:
......
EOF

This format is used when creating configuration files. The first command tells the system to create the file $LFS/etc/group from whatever is typed on the following lines until the sequence End Of File (EOF) is encountered. Therefore, this entire section is generally typed as seen.

<REPLACED TEXT>

This format is used to encapsulate text that is not to be typed as seen or for copy-and-paste operations.

[OPTIONAL TEXT]

This format is used to encapsulate text that is optional.

passwd(5)

This format is used to refer to a specific manual (man) page. The number inside parentheses indicates a specific section inside the manuals.

For example, passwd has two man pages. Per LFS installation instructions, those two man pages will be located at /usr/share/man/man1/passwd.1 and /usr/share/man/man5/passwd.5 . When the book uses passwd(5) it is specifically referring to /usr/share/man/man5/passwd.5 .

man passwd will print the first man page it finds that matches “passwd,” which will be /usr/share/man/man1/passwd.1 . For this example, you will need to run man 5 passwd in order to read the page being specified.

Note that most man pages do not have duplicate page names in different sections. Therefore, man<program name> is generally sufficient. In the LFS book these references to man pages are also hyperlinks, so clicking on such a reference will open the man page rendered in HTML from Arch Linux manual pages.

Structure

This book is divided into the following parts.

Part I - Introduction

Part I explains a few important notes on how to proceed with the LFS installation. This section also provides meta- information about the book.

Part II - Preparing for the Build

Part II describes how to prepare for the building process—making a partition, downloading the packages, and compiling temporary tools.

Part III - Building the LFS Cross Toolchain and Temporary Tools

Part III provides instructions for building the tools needed for constructing the final LFS system.

Part IV - Building the LFS System

Part IV guides the reader through the building of the LFS system—compiling and installing all the packages one by one, setting up the boot scripts, and installing the kernel. The resulting Linux system is the foundation on which other software can be built to expand the system as desired. At the end of this book, there is an easy to use reference listing all of the programs, libraries, and important files that have been installed.

Part V - Appendices

Part V provides information about the book itself including acronyms and terms, acknowledgments, package dependencies, a listing of LFS boot scripts, licenses for the distribution of the book, and a comprehensive index of packages, programs, libraries, and scripts.

Errata and Security Advisories

The software used to create an LFS system is constantly being updated and enhanced. Security warnings and bug fixes may become available after the LFS book has been released. To check whether the package versions or instructions in this release of LFS need any modifications—to repair security vulnerabilities or to fix other bugs—please visit https:// www.linuxfromscratch.org/lfs/errata/12.4/ before proceeding with your build. You should note any changes shown and apply them to the relevant sections of the book as you build the LFS system.

In addition, the Linux From Scratch editors maintain a list of security vulnerabilities discovered after a book has been released. To read the list, please visit https://www.linuxfromscratch.org/lfs/advisories/ before proceeding with your build. You should apply the changes suggested by the advisories to the relevant sections of the book as you build the LFS system. And, if you will use the LFS system as a real desktop or server system, you should continue to consult the advisories and fix any security vulnerabilities, even when the LFS system has been completely constructed.