Part 1: Introduction and Prerequisites
Overview
This guide covers building a complete Linux distribution from scratch. The project is divided into two main approaches:
- Simple Approach - "No Bloat Linux" using minimal packages (Phase 1 only)
- Complete Approach - Linux From Scratch (LFS) full system build
What You'll Build
Phase 1: Minimal Installation System
- Bootable USB/ISO installer
- Based on BusyBox utilities
- Includes: Linux kernel, glibc, BusyBox, Bash, sysvinit
- Purpose: Installation program only
Phase 2: Full Linux Distribution
- Complete operating system
- 102 packages from source
- Customizable and bloat-free
- Fully functional desktop capable
Two Build Approaches
Approach 1: No Bloat Linux (Minimal)
- Quick setup (~1-2 days)
- Minimal package set
- 32-bit or 64-bit support
- Good for learning basics
Approach 2: Linux From Scratch (Complete)
- Comprehensive build (~1-2 weeks)
- 102 packages
- Full documentation
- Production-ready system
Architecture Choice
32-bit (i386)
make i386_defconfig
64-bit (x86_64)
make x86_64_defconfig
Important: Compile all packages on matching architecture (32-bit system for 32-bit dist, 64-bit for 64-bit).
System Requirements
Hardware Requirements (Recommended)
- CPU: 4+ cores (minimum 1 core)
- RAM: 8 GB (minimum 4 GB)
- Disk: 35 GB free space (minimum 10 GB for Phase 1)
- Partition: Dedicated partition for build
Host System Requirements
Your existing Linux system must have these tools installed:
| Software | Minimum Version | Notes |
|---|---|---|
| Bash | 3.2 | /bin/sh must link to bash |
| Binutils | 2.13.1 | Versions >2.45 untested |
| Bison | 2.7 | /usr/bin/yacc should link to bison |
| Coreutils | 8.1 | — |
| Diffutils | 2.8.1 | — |
| Findutils | 4.2.31 | — |
| Gawk | 4.0.1 | /usr/bin/awk must link to gawk |
| GCC | 5.4 | Includes g++; versions >15.2.0 untested |
| Grep | 2.5.1a | — |
| Gzip | 1.3.12 | — |
| Linux Kernel | 5.4 | Must support UNIX 98 PTY |
| M4 | 1.4.10 | — |
| Make | 4.0 | — |
| Patch | 2.5.4 | — |
| Perl | 5.8.8 | — |
| Python | 3.4 | — |
| Sed | 4.1.5 | — |
| Tar | 1.22 | — |
| Texinfo | 5.0 | — |
| Xz | 5.0.0 | — |
Version Check Script
Create and run this script to verify your system:
#!/bin/bash
# version-check.sh - Check host system requirements
# Save to version-check.sh and run: bash version-check.sh
export LC_ALL=C
bash --version | head -n1 | cut -d" " -f2-4
MYSH=$(readlink -f /bin/sh)
echo "/bin/sh -> $MYSH"
echo $MYSH | grep -q bash || echo "ERROR: /bin/sh does not point to bash"
unset MYSH
echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-
bison --version | head -n1
if [ -h /usr/bin/yacc ]; then
echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`";
elif [ -x /usr/bin/yacc ]; then
echo yacc is `/usr/bin/yacc --version | head -n1`
else
echo "yacc not found"
fi
echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2
diff --version | head -n1
find --version | head -n1
gawk --version | head -n1
if [ -h /usr/bin/awk ]; then
echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`";
elif [ -x /usr/bin/awk ]; then
echo awk is `/usr/bin/awk --version | head -n1`
else
echo "awk not found"
fi
gcc --version | head -n1
g++ --version | head -n1
grep --version | head -n1
gzip --version | head -n1
cat /proc/version
m4 --version | head -n1
make --version | head -n1
patch --version | head -n1
echo Perl `perl -V:version`
python3 --version
sed --version | head -n1
tar --version | head -n1
makeinfo --version | head -n1 # texinfo version
xz --version | head -n1
echo 'int main(){}' > dummy.c && g++ -o dummy dummy.c
if [ -x dummy ]
then echo "g++ compilation OK";
else echo "g++ compilation failed"; fi
rm -f dummy.c dummy
Trusted Sources Only
All packages must come from trusted sources:
- kernel.org - Linux kernel and utilities
- gnu.org - GNU tools and libraries
- Official project sites - Listed in package manifest
Never use:
- Random patches from unknown domains
- Unofficial mirrors
- Modified sources from untrusted repositories
Build Time Estimates
No Bloat Linux (Phase 1)
- 4-core system: 2-4 hours
- 8-core system: 1-2 hours
- Single core: 8-12 hours
Linux From Scratch (Full)
- 4-core system: 1-2 days
- 8-core system: 12-24 hours
- Single core: 3-5 days
Note: Times vary based on CPU speed, disk I/O, and system load.
Understanding SBU (Standard Build Units)
LFS uses SBU to estimate build times:
- 1 SBU = Time to build Binutils (first package)
- Other packages measured in SBUs
- Example: If Binutils takes 10 minutes, a 2 SBU package takes 20 minutes
Track your SBU:
time { ./configure && make && make install; }
First Binutils build time becomes your reference SBU.
Next Steps
After verifying your system meets requirements:
- Part 2: Prepare host system (partition, filesystem, environment)
- Part 3: Download all required packages
- Part 4: Build cross-compilation toolchain
- Part 5+: Continue with system build
Resources
- Linux From Scratch Official Site
- LFS Stable Book
- LFS Development Version
- Beyond Linux From Scratch (BLFS)
Important Notes
- Read all instructions before starting
- Don't skip version checks
- Keep notes of your build process
- Test in virtual machine first (recommended)
- Back up important data before partitioning