This repository contains a complete Linux From Scratch (LFS) 12.0 with automated installation scripts and system packaged as Docker images for easy reproducibility and testing. The project provides multiple Docker image variants optimized for different use cases.
lfs12/
├── lfs12/ # Complete LFS filesystem
├── docker-lfs.sh # Docker management script
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Base LFS image (~970MB)
├── Dockerfile.optimized # Optimized image (~950MB)
├── Dockerfile.minimal # Minimal development image (~600MB)
├── install-lfs.sh # LFS installation script
└── runUsingQemu/ # QEMU-based execution scripts
Before installing LFS, building Docker images or using QEMU, you need to download the pre-built LFS 12.0 filesystem:
-
Download from GitHub Releases:
# Download the latest lfs12.tar.gz from GitHub releases wget https://github.com/aunchagaonkar/lfs12/releases/latest/download/lfs12.tar.gz -
Alternative: Using curl:
# Download using curl curl -L -o lfs12.tar.gz https://github.com/aunchagaonkar/lfs12/releases/latest/download/lfs12.tar.gz -
Extract the filesystem:
# Extract to lfs12/ directory tar -xzf lfs12.tar.gz # Verify extraction ls -la lfs12/
You can install LFS directly on a dedicated system using the installation script. Make sure you have downloaded and extracted the LFS filesystem first.
# Install LFS to a target devic
./install-lfs.sh -s ./lfs12 -t /dev/sdX1 -b /dev/sdXSee the script's help for more options:
./install-lfs.sh --helpThe docker-lfs.sh script provides comprehensive Docker management:
- Automatic image selection: Prefers smaller images when available
- Build variants: Support for different optimization levels
- Container lifecycle: Start, stop, cleanup operations
- Resource monitoring: Size and usage statistics
- Safety features: Automatic cleanup and error handling
./docker-lfs.sh [COMMAND] [OPTIONS]
Commands:
build [basic|optimized|minimal] Build Docker image (default: basic)
run [interactive|daemon|test] Run container (default: interactive)
stop Stop running container
clean Clean up all LFS Docker resources
stats Show Docker usage statistics
shell Open shell in running containerUse the provided management script:
# Make the script executable
chmod +x docker-lfs.sh
# Build the base image
./docker-lfs.sh build basic
# Build the minimal image (recommended for most use cases)
./docker-lfs.sh build minimal
# Build the optimized image
./docker-lfs.sh build optimized# Run interactively (default - uses smallest available image)
./docker-lfs.sh run
# Run in daemon mode
./docker-lfs.sh run daemon
# Run a quick test
./docker-lfs.sh run test
# Connect to running container
./docker-lfs.sh shell# Show usage statistics
./docker-lfs.sh stats
# Stop running container
./docker-lfs.sh stop
# Clean up all LFS Docker resources
./docker-lfs.sh clean
# Show help
./docker-lfs.sh helpYou can run the LFS system inside a QEMU virtual machine for full system emulation (no Docker required).
Ensure you have downloaded and extracted the LFS filesystem in the repo as described in the "Getting the LFS Filesystem" section above.
-
First, create the disk image:
cd runUsingQemu/ ./create-img.shBy default, the generated
lfs12.imgfile is owned byroot. To use it as a regular user, change ownership:sudo chown $USER:$USER lfs12.img
-
Then, run the LFS system in QEMU:
./run-lfs.sh
-
The default user is
rootand passwordnova@123.
- Tag:
lfs12:latest - Size: ~970MB
- Description: Complete LFS system with all tools and documentation
- Use Case: Full development environment and learning
- Tag:
lfs12:optimized - Size: ~950MB
- Description: Cleaned up system with optimizations
- Use Case: Production-ready environment with minor cleanup
- Tag:
lfs12:minimal - Size: ~475MB
- Description: Development tools kept, documentation removed
- Use Case: Lightweight development environment
- Docker installed and running
- At least 2GB free disk space
- Linux, macOS, or Windows with WSL2
- LFS Version: 12.0
- Kernel: 6.4.12-lfs-12.0
- Architecture: x86_64
- Base System: Complete from-scratch Linux system
- Package Manager: None (pure LFS)
- Init System: SysV init
The LFS system includes essential tools:
- GCC toolchain
- Glibc
- Bash shell
- Core utilities (coreutils, findutils, etc.)
- Text editors (nano, vim)
- Network tools
- Development libraries
- And many more essential packages
Each image can be tested using:
# Quick functionality test
./docker-lfs.sh run test
# Interactive testing
./docker-lfs.sh run interactive
# Then inside the container:
uname -a
ls -la /
gcc --version-
Docker permission errors:
sudo usermod -aG docker $USER # Then logout and login again
-
Out of disk space:
docker system prune -a ./docker-lfs.sh clean
-
Container won't start:
./docker-lfs.sh stop ./docker-lfs.sh clean ./docker-lfs.sh build minimal
- Minimum RAM: 256MB
- Recommended RAM: 1GB+
- Disk Space:
- Base image: ~1GB
- Minimal image: ~600MB
- Build process: ~2GB temporary space
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Test your changes with all image variants
- Submit a pull request
This project is licensed under the GPL 3.0 License - see the LICENSE file for details.
- Linux From Scratch Project
- LFS 12.0 documentation and community
- Docker community for containerization best practices