Skip to content
ALB Wiki

LFS System Packages

This is an old revision of this page — revision 1 (2026-10-25 14:48:41 UTC). It may differ from the current revision.

This is the marathon chapter — some fifty packages compiled inside the chroot by the toolchain you built, installing the real system's libraries, utilities, and compilers. Where chapter 4 cross-compiled the scaffolding, chapter 5 builds natively — the temporary toolchain producing the final toolchain and everything around it. The pattern never changes: extract, configure, make, test, install, delete the tree. What changes is the scale — and the discipline the scale demands.

The shape of the marathon

The book's chapter 8 is a long procession. Grouped by role, it runs roughly:

  • Compression + archive — zstd, xz, bzip2, gzip, tar
  • Foundation libraries — zlib, ncurses (real install), readline, libffi, expat, libxml2, libxcrypt
  • Build machinery — m4, bison, flex, autoconf, automake, libtool, pkgconf, check, libtasn1
  • The toolchain, natively — binutils, gmp, mpfr, mpc, isl, gcc — the real ones this time
  • Core userland — attr/acl, shadow (login/passwd/su), bash, coreutils, diffutils, findutils, gawk, grep, sed, procps-ng, psmisc, util-linux, e2fsprogs, file, inetutils, less, iproute2, kbd, kmod, patch, vim
  • Scripting — perl, python, wheel/setuptools, ninja, meson, texinfo, gettext
  • System plumbing — elfutils, libelf, libpipeline, man-db, man-pages, groff, sysklogd, sysvinit, eudev, dbus-adjacent pieces
  • Security — openssl, libcap-ng, markupsafe/jinja2 adjacents, gperf, libseccomp

Each is the same liturgy with its own flags and fix-ups — fifty variations on a theme you've already played fifteen times.

The ritual, refined

cd /sources                 # inside chroot — no $LFS prefix anymore
tar -xf xz-*.tar.xz
cd xz-*/
./configure --prefix=/usr    \
            --disable-static \
            --docdir=/usr/share/doc/xz-<ver>
make
make check                   # run the testsuite where the book says to
make install
cd .. && rm -rf xz-*/

The refinements inside the chroot: --prefix=/usr without DESTDIR — you're really installing now; --disable-static avoids shipping static libraries where shared ones serve; make check runs testsuites the book flags as skippable-only-at-your-peril. A failing testsuite inside the chroot is a real failure — unlike the temp stage, these packages are the finished product.

The three packages that matter most

GCC (native) — the final compiler, all languages, threads, libstdc++ complete. After it, the cc→gcc link is permanent, and the toolchain you just built replaces the one that built it — the build pulls itself up by its own bootstraps.

Binutils (native) — the linker the finished system will use.

Shadow — the login/password suite: useradd, passwd, su, login itself. Its install turns /etc/passwd from the chapter-4 placeholder into a real account database, and includes the crypto bindings (via libxcrypt) that make passwd hash properly.

The toolchain verification — the second proof of life

After binutils+gcc install, the book's toolchain check verifies the real compiler:

echo 'int main(){}' > dummy.c
cc dummy.c -v -Wl,--verbose &> dummy.log
readelf -l a.out | grep ': /lib'
# correct: [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
# (or /lib/ld-linux.so.2 on 32-bit)
grep -E -o '/usr/lib.*/S?crt[1in].*succeeded' dummy.log   # crt files found
grep 'SEARCH.*/usr/lib' dummy.log | sed 's|; |\n|g'        # search paths right
grep found dummy.log                                      # right libstdc++
rm -v dummy.c a.out dummy.log

This is chapter 5's readelf moment — the native toolchain proving it looks inward, not at the host.

The marathon's pacing

Fifty packages take most of a day even on modern hardware. Pace and hygiene:

  • Re-extract every tarball fresh — leftover configure caches from earlier passes are a classic poisoner
  • Delete the tree after install — disk and confusion both
  • make check where the book asks — a test failure now is a bug found cheap; skip it and the bug resurfaces at boot
  • Read the "Contents" + "Short Descriptions" per package — you should know what you installed; that's the whole point of LFS
  • Log everything — the journal from chapter 2 pays off when package 47 misbehaves

The cleanup and the system that emerges

Late in the chapter, the book strips debugging symbols and removes the scaffolding:

rm -rf /tmp/{*,.*}                # build residue
find /usr/lib /usr/libexec -name \*.la -delete   # dead libtool files
find /usr -depth -name \( -name \*.o -o -name \*.a \) ! -name \*libc_nonshared.a -delete
strip --strip-unneeded /usr/bin/* /usr/lib/* 2>/dev/null  # optional, per book

Then temporary tools come out — the /tools tree and the now-redundant packages it enabled get removed, shrinking the system to just what the real packages installed. What's left is a complete Linux userspace: shell, utilities, compiler, libraries, account machinery, log files — everything but a kernel and a boot.

The Iana-Etc / man-pages / man-db trio

Three quiet packages make the system human: iana-etc supplies /etc/services and /etc/protocols (the name↔number maps every network tool leans on); man-pages gives you documentation for the kernel interfaces you built against; man-db makes man work. Skipping them gives a system that functions but can't be questioned.

Where this chapter goes wrong

SymptomCause
Testsuite failures across many packagesTemp system incomplete — back to chapter 4
configure can't find a lib it should findOrdering — the book's sequence is dependency-sorted; out-of-order builds fail
/usr/lib paths wrong in binariesprefix flag missed — --prefix=/usr vs DESTDIR confusion
cc missing late in the chaptergcc pass-2's symlink skipped
su/passwd brokenShadow's libxcrypt/PAM flags wrong
Disk full mid-chapterOld build trees not deleted — rm -rf after each install
Package installs to /toolsconfigure prefix accidentally still /tools

Exercises

  1. Pick any package; write its configure line before reading the book's — compare.
  2. Find three packages whose make check is explicitly skippable — and three where it isn't. Why the difference?
  3. ldd three freshly-built binaries — prove they link the chroot's glibc, not the host's.
  4. Track your build times — which package burned the most SBUs? (Usually gcc.)
  5. Explain why /etc/services matters — find a tool that consults it.

Timeline

StepResult
~50 packagesThe real userspace, natively built
Native binutils+gccThe system compiles itself
ShadowReal accounts, real passwords
Verificationreadelf proves inward-looking toolchain
CleanupTemp tools out, symbols stripped
nextLFS IV — kernel, bootloader, first boot

References

  • linuxfromscratch.org — chapter 8: installing basic system software; stripping; cleaning
  • Each package's own documentation — the book's flags come from upstream

See also

Categories: Handbook · LFS · Linux · Linux Handbook
This page was last edited 2026-10-25 14:48:41 UTC by ALB Team. What links here