Skip to content

Make your own Linux Distro From scratch

I'll call my distro name as: TiniLinux

Welcome to TiniLinux, we will make a Linux Distro from scratch

Theory

To make a very tiny and simple Linux distro, we're going to need:

  • Kernel
  • User Space (in this case we use BusyBox)
  • Bootloader (in this case we use Grub)
              ┌────────────────────┐                     
              │     Power On       │                     
              │                    │                     
              └─────────┬──────────┘                     
              ┌─────────▼──────────┐                     
              │     BIOS/UEFI      │                     
              │                    │                     
              │       (POST)       │                     
              └─────────┬──────────┘                     
              ┌─────────▼──────────┐                     
              │    Boot Device     │                     
              │                    │                     
              │  Hard Disk/CD/USB  │                     
              └─────────┬──────────┘                     
              ┌─────────▼──────────┐                     
              │  Boot Loader(GRUB) │                     
              │                    │                     
              │  Load kernel and   │                     
              │  initramfs to RAM  │                     
              └──────────┬─────────┘                     
              ┌──────────▼─────────┐                     
              │       Kernel       │                     
              │                    │                     
              │ Execute /sbin/init │                     
              └──────────┬─────────┘                     
           (Live boot)   │  (Boot from Hard disk)        
           ┌─────────────┴──────────────┐                
           │                            │                
┌──────────▼─────────┐       ┌──────────▼─────────┐      
│   Init (initramfs) │       │  Init (initramfs)  │      
│                    │       │  Mount Real rootfs │      
│   Execute RunLevel │       │  from hard disk    │      
│      programs      │       │  then switch_root  │      
│                    │       │  exec /sbin/init   │      
└────────────────────┘       └──────────┬─────────┘      
                             ┌──────────▼─────────┐      
                             │        Init        │      
                             │                    │      
                             │   Execute RunLevel │      
                             │      programs      │      
                             └──────────┬─────────┘      
                             ┌──────────▼─────────┐      
                             │  Systemd / OpenRC  │      
                             │                    │      
                             │   Execute System   │      
                             │   Daemon programs  │      
                             └────────────────────┘      

(Drew with https://asciiflow.com/)

This applies to real world Linux distro as well (Debian, Ubuntu, Fedora,...)

Steps

This page is a WIP, check back later for more contents

Here is a guide how to make a simple Linux Distro from scratch.

  1. Setup Environment
  2. Compile the kernel
  3. Compile Busybox
  4. Creating the initial ram filesystem (initramfs)
  5. Configuring the bootloader
  6. Package manager
  7. Docker
  8. Install to hard drive
  9. Appendix

References