Skip to content

Linux From Scratch

You'll build an entire operating system from source code by following the LFS book, from the first toolchain to a kernel that boots to a login prompt you compiled yourself.

About

Linux From Scratch is a free book that walks you through compiling every piece of a working system by hand: a cross toolchain, then glibc, then every tool in the base system, then the kernel, in that order, because each one is needed to build the next. It takes a season of evenings and a lot of waiting for compiles. Nobody uses the result as a daily system, and that isn't the point. When it boots, you'll know what every file on a Linux system is for and which package put it there, because you did. Do it on a VM or a spare disk, and keep a log, because a typo in chapter five shows up as a failure in chapter eight.

At a glance

Per requirement
50 XP
Completion bonus
600 XP
Requirements
6
Takes
A season
Skill level
Advanced (years of practice)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
On your own
Locked for now
Earn two more Rare badges in Linux to open this one. Log in to see how far along you are.

Requirements

  1. 1
    Prepare the host and the target partition and pass the version check. Run the book's version-check script on your host and fix anything it complains about. Make the LFS partition, mount it at the path the LFS variable points to, and download all the sources listed in the book. Take a photo of the version check passing and the sources directory listing. Photo
  2. 2
    Build the cross toolchain and the temporary tools. That's binutils, gcc, the kernel headers, glibc and the first pass of the rest, built as the dedicated lfs user the book tells you to make. This is the part people get wrong by skipping a step they thought was ceremony. Take a photo of the chroot into the temporary system working. Photo
  3. 3
    Build the final system and keep a log of every package. Chapter eight is the long one, with each package compiled, tested where the book says, and installed. Keep a file with the date, the package and whether the test suite passed. Take a photo of the log at the end of the chapter. Photo
  4. 4
    Configure the system, build the kernel, and set up the bootloader. Write fstab, the network config, the boot scripts or systemd units, and compile the kernel with a config you made. Install GRUB or add an entry to your existing bootloader. Take a photo of the kernel config and the bootloader entry. Photo
  5. 5
    Boot into it and log in. Reboot, choose the LFS entry, and get a login prompt that nothing but your own compiled code produced. Film the boot from the bootloader to the shell prompt, with the release file showing it's your build. Video
  6. 6
    Write the three things you understand now that you didn't before. Keep it honest and specific, like what a dynamic linker actually does or why the toolchain is built twice. Take a photo of the note next to the running system. Photo