ft_linux is an advanced systems engineering project based on the Linux From Scratch (LFS) documentation. The objective is to build a custom, minimal Linux distribution by compiling every single component from source code—from the Binutils and GCC compiler to the Bash shell and the Linux Kernel itself.
This project is the ultimate test of understanding how an Operating System is put together. It moves beyond "administering" a system to "architecting" one, requiring a deep understanding of dynamic linking, compiler toolchains, and the boot process.
- Toolchain Construction: Solving the "chicken and egg" problem by building a cross-compiler (Binutils, GCC, Glibc) to build the final system.
- Dependency Hell Management: Manually resolving shared library dependencies for core utilities without
apt,yum, orpacman. - Kernel Compilation: Configuring (
make menuconfig) and building a monolithic Linux Kernel tailored specifically to the host hardware. - Bootloader Setup: Manually installing and configuring GRUB to hand off control to the kernel image.
The construction process follows a strict 3-stage isolation model to prevent the host system's libraries from contaminating the new distribution.
graph LR
A[Host System] -->|Builds| B(Temporary Toolchain)
B -->|Builds inside Chroot| C(Final System)
C -->|Bootable| D[ft_linux Distro]
- Stage 1 - Cross-Toolchain: Building a hardware-agnostic compiler and linker.
- Stage 2 - Temporary Tools: Building a minimal set of isolated tools (
/tools) linked against the new Glibc. - Stage 3 - Final System: Entering the
chrootenvironment to build the permanent system binaries (/bin,/usr/bin) using the temporary tools.
The most critical part of the project was compiling the GNU C Library (Glibc). Since every program in the system depends on it, it had to be compiled with absolute precision to ensure it linked correctly to the new dynamic loader (ld-linux.so), decoupling it completely from the host OS.
Instead of using a generic distribution kernel (which includes drivers for every possible hardware), I stripped the kernel down to the bare essentials:
- Filesystems: Added support only for
ext4. - Drivers: Included only virtio/SATA drivers required for the disk.
- Network: Enabled TCP/IP stack but removed legacy protocols.
- Result: A kernel image significantly smaller and faster to boot than standard kernels.
I manually created the Unix directory hierarchy standard (FHS):
/etcfor configuration (fstab, hosts, passwd)./devpopulated viamknodordevtmpfsmounting./procand/sysvirtual filesystems for kernel interaction.
The successful completion of the project is defined by the ability to boot the machine independently and perform basic system operations:
- Boot Process: The BIOS loads GRUB, which successfully loads the compiled
vmlinuzkernel. - Init System: The kernel mounts the root filesystem (
/) and executes/sbin/init. - User Space: A login prompt appears (
getty), allowing entry asroot. - Networking: The network interface (
eth0) is up and capable of connecting to the internet via ping/ssh.
Built by Eleder Andres. "Where there is a shell, there is a way."