Thanks to visit codestin.com
Credit goes to github.com

Skip to content

aunchagaonkar/lfs12

Repository files navigation

Linux From Scratch (LFS) 12.0

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.

Repository Structure

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

Getting the LFS Filesystem

Before installing LFS, building Docker images or using QEMU, you need to download the pre-built LFS 12.0 filesystem:

  1. 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
  2. Alternative: Using curl:

    # Download using curl
    curl -L -o lfs12.tar.gz https://github.com/aunchagaonkar/lfs12/releases/latest/download/lfs12.tar.gz
  3. Extract the filesystem:

    # Extract to lfs12/ directory
    tar -xzf lfs12.tar.gz
    
    # Verify extraction
    ls -la lfs12/

Direct Installation

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/sdX

See the script's help for more options:

./install-lfs.sh --help

Docker Management Script Features

The 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

Script Usage

./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 container

Building Images

Use 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

Running Containers

# 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

Management Commands

# 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 help

QEMU

You can run the LFS system inside a QEMU virtual machine for full system emulation (no Docker required).

Prerequisites

Ensure you have downloaded and extracted the LFS filesystem in the repo as described in the "Getting the LFS Filesystem" section above.

Installation Steps

  1. First, create the disk image:

    cd runUsingQemu/
    ./create-img.sh

    By default, the generated lfs12.img file is owned by root. To use it as a regular user, change ownership:

    sudo chown $USER:$USER lfs12.img
  2. Then, run the LFS system in QEMU:

    ./run-lfs.sh
  3. The default user is root and password nova@123.

Available Docker Images

1. Base Image (Dockerfile)

  • Tag: lfs12:latest
  • Size: ~970MB
  • Description: Complete LFS system with all tools and documentation
  • Use Case: Full development environment and learning

2. Optimized Image (Dockerfile.optimized)

  • Tag: lfs12:optimized
  • Size: ~950MB
  • Description: Cleaned up system with optimizations
  • Use Case: Production-ready environment with minor cleanup

3. Minimal Image (Dockerfile.minimal)

  • Tag: lfs12:minimal
  • Size: ~475MB
  • Description: Development tools kept, documentation removed
  • Use Case: Lightweight development environment

Quick Start

Prerequisites

  • Docker installed and running
  • At least 2GB free disk space
  • Linux, macOS, or Windows with WSL2

System Information

  • 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

Included Software

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

Testing the Images

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

Troubleshooting

Common Issues

  1. Docker permission errors:

    sudo usermod -aG docker $USER
    # Then logout and login again
  2. Out of disk space:

    docker system prune -a
    ./docker-lfs.sh clean
  3. Container won't start:

    ./docker-lfs.sh stop
    ./docker-lfs.sh clean
    ./docker-lfs.sh build minimal

Resource Requirements

  • Minimum RAM: 256MB
  • Recommended RAM: 1GB+
  • Disk Space:
    • Base image: ~1GB
    • Minimal image: ~600MB
    • Build process: ~2GB temporary space

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Test your changes with all image variants
  4. Submit a pull request

License

This project is licensed under the GPL 3.0 License - see the LICENSE file for details.

Acknowledgments

About

Linux From Scratch Version 12

Topics

Resources

License

Stars

Watchers

Forks

Packages