An educational Bash script that guides you through the process of building a minimal Linux distribution from scratch, using the Linux kernel and BusyBox.
- Step-by-step guidance: A fully interactive, menu-driven script that explains each step of the build process.
- Kernel Compilation: Automatically downloads, configures, and compiles the latest Linux kernel LTS version.
- Minimal Filesystem: Creates a minimal root filesystem with BusyBox, a single executable containing many core Unix utilities.
- Initramfs Generation: Builds an
initramfs(initial RAM filesystem) required for booting. - Bootable ISO: Creates a bootable ISO image using GRUB, ready to be burned to a CD/DVD or used in a VM.
- QEMU Integration: Easily test your newly created Linux system with a single menu option using QEMU.
- Prerequisite Check: Automatically detects and offers to install all necessary packages on Debian/Ubuntu-based systems.
This script is designed for Debian/Ubuntu based systems. It will automatically check for and offer to install the required packages:
build-essentialflexlibncurses5-devbclibelf-devbisonlibssl-devgrub-pc-binxorrisomtoolswgetqemu-system-x86
-
Clone the repository (or download the script):
git clone https://github.com/manzolo/linux-builder.git cd linux-builder -
Make the script executable:
chmod +x builder.sh
-
Run the script:
./builder.sh
-
Follow the on-screen menu to perform the build operations. It is recommended to follow the steps in order:
Check prerequisitesPrepare Linux kernelPrepare BusyBox (filesystem)Test system with QEMUorCreate bootable ISO image
The script automates the manual process of building a Linux system:
- It first downloads the Linux kernel source code and compiles it to create the
bzImagefile. - It then downloads and compiles BusyBox as a static binary, which bundles together common commands like
ls,cat, andsh. - A basic
initscript is created to mount virtual filesystems and provide a minimal shell. - BusyBox and the
initscript are packaged together into aninitramfs.cpio.gzfile. - Finally, the
bzImageandinitramfsare used with QEMU for testing or combined with a GRUB configuration to create a bootable ISO image.
You can easily customize the project by changing the KERNEL_VERSION and BUSYBOX_VERSION variables at the beginning of the config.sh script.
This project is licensed under the MIT License.
This script is inspired by and based on the guide from ThyCrow: Compiling the Linux Kernel and Creating a Bootable ISO from it
These images show the key steps of the compilation process and the final result.
The initial screen showing all available options.

The kernel configuration menu, where you can customize options.

The BusyBox compilation output, which creates a minimal filesystem.

The system booted with the QEMU emulator.

The GRUB bootloader of the final ISO image.
