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.
- Setup Environment
- Compile the kernel
- Compile Busybox
- Creating the initial ram filesystem (initramfs)
- Configuring the bootloader
- Package manager
- Docker
- Install to hard drive
- Appendix
References¶
- https://www.youtube.com/watch?v=QlzoegSuIzg
- https://medium.com/@ThyCrow/compiling-the-linux-kernel-and-creating-a-bootable-iso-from-it-6afb8d23ba22
- https://medium.com/@GlobularOne/how-to-make-a-minimal-linux-distribution-from-source-code-5ff9b48dfc2
- https://gist.github.com/m13253/e4c3e3a56a23623d2e7e6796678b9e58
- https://kmahyyg.medium.com/tiny-image-dropbear-with-busybox-6f5b65a44dfb
- https://github.com/vmware/open-vm-tools/issues/696#issuecomment-1812710977 http://wiki.loverpi.com/faq:sbc:libre-aml-s805x-minimal-rootfs
- https://dariodip.medium.com/understanding-linux-containers-a-simple-recipe-7c24cc1137b4