Linux From Scratch
This is a breakdown of the LFS book.
- sticky bit - file can be removed only by its owner even if directory is
accessible to multiple users.
/tmpuses 777 with sticky-bit. Thanks to it anyone is able to create/read/execute in
/tmp, but only owner of a given file can remove it.
- login and non-login shell - login shell loads
bash_profile(which loads other things like
.bashrc). Non-login shell may be started only when login shell session exists, and it loads
Cross-compiler is a compiler that builds programs on machine A, but the programs are supposed to run on machine B.
Some of the most important packages on linux:
- binutils - contains
as(assembler), and lots of other tools
- glibc - GNU standard C library (provides basic things like
- gcc - GNU Compiler Collection (C and C++ among others)
- libgcc - internal library used by GCC
The installation order:
- binutils - linker and assembler are required by gcc’s and glibc’s
- sanitized Linux API headers - allows glibc to interface with kernel’s features
Package manager tracks the files installed by applications making it easy to update and remove software.
- installing each package in separate directory, and creating a symlink to
executable in some shared directory (e.g.
- timestamp-based - package manager records the time of package installation. Later it can find package’s files by looking at timestamp of the files on the system. This will not work if multiple packages are being installed at the same time.
- package archives - RPMs and DEBs use that. The package’s structure is made in an archive and recreated on the target system.
- Kernel 3.2 - I have 5.x…
- After downloading all packages from FTP, and checking their md5 I got the
md5sum: man-pages-5.12.tar.xz: No such file or directory. It turns out that FTP had version 5.13 of that package only. Is it a problem?
Chapter 2 - prerequisites
- Install Ubuntu 20.04 in a VM (I used Gnome Boxes)
- Install all the missing packages (accoridng to version-check.sh)
- Create a new partition for LFS (~20GB) and mount it.
/sourcesdirectory on the LFS partition.
Chapter 3 - downloading sources
- Download all software packages and patches from the FTP mirror of LFS, and check md5 checksums.
Chapter 4 - bootstrap LFS partition
- Create some dirs in LFS partition (
/toolsdirectory for cross-compiler to be installed in.
lfsuser and group to the host system.
chowndirectories in the LFS partition by the
- Log in as
lfsin a terminal session.
Chapter 5 - building cross-compiler and its associated tools
- Build Binutils (pass 1)
- Build GCC (pass 1)
- Build sanitized Linux API headers
- Build glibc
- Build libstdc++ (pass 1)
Chapter 6 - cross-compiling temporary tools
- Build M4
- Build Ncurses
- Build Bash
- Build Coreutils
- Build Diffutils - by mistake I did make install before make. Later I rerun make install. Is it OK?
- Build File - File on host needs to be in version 5.40? I have 5.38
- Build Findutils
- Build Gawk
- Build Grep
- Build Gzip
- Build Make
- Build Patch
- Build sed
- Build tar
- Build Xz
- Build Binutils (pass 2)
- Build GCC (pass 2)
Chapter 7 - chroot
- Change ownership of dirs in $LFS to root.
- Create console and null devices in $LFS/dev.
- Mount Virtual Kernel File Systems on $LFS (
- Chroot on
$LFS/etc/passwddoesn’t exist so “I have no name!” will appear instead of user name in bash.
- Create Linux directories according to FHS (Filesystem Hierarchy Standard).
- Create “tester” user (needed for some tests later on).
- Start a new shell to make use of the
/etc/group. Shell now properly shows “root” as a user.
- Create files for logs for various programs (login, agetty, init)
- Build Libstdc++ (pass 2).
- Build Gettext.
- Build Bison.
- Build Perl.
- Build Python.
- Build Texinfp.
- Build Util-linux
- Cleanup doc files and .la files
- Delete the
$LFS/toolsdirectory, we no longer need it.
- Backup current work (
- Build man-pages
- Copy Iana-Etc
- Build and test Glibc - hard to say if
make checkwas successful or not (44 fails, 67 unsupported, 16 xfail)
- Install locales, timezones
- Build Zlib
- Build Bzip2
- Build Xz
- Build File
- Build Readline
page 116 (M4 is next)