Skip to content

Latest commit

 

History

History
97 lines (73 loc) · 2.87 KB

make-isoimage.md

File metadata and controls

97 lines (73 loc) · 2.87 KB

Bootable Linux ISO Build Process

This guide explains how to create a custom bootable Linux ISO image using Syslinux bootloader and a minimal initramfs.

Prerequisites

Required packages on Ubuntu/Debian:

sudo apt update
sudo apt install build-essential git curl tar

You'll need about 3GB of free disk space for the build process.

Build Steps

1. Download Initial RAM Filesystem (initramfs)

The initramfs provides the minimal root filesystem needed during the boot process.

# Download and extract minimal initramfs for boot initialization
curl -sL https://landley.net/bin/mkroot/0.8.12/x86_64.tgz | \
  tar -xz -C ~ -f - --strip-components=1 x86_64/initramfs.cpio.gz

2. Install Syslinux Bootloader Components

Syslinux provides the bootloader infrastructure needed to create bootable media.

# Download and configure Syslinux bootloader elements
curl -sL https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.xz | \
  tar -xJf - \
    syslinux-6.03/bios/core/isolinux.bin \
    syslinux-6.03/bios/com32/elflink/ldlinux/ldlinux.c32 && \
  sudo mkdir -p /usr/lib/syslinux && \
  sudo mv \
    syslinux-6.03/bios/core/isolinux.bin \
    syslinux-6.03/bios/com32/elflink/ldlinux/ldlinux.c32 \
    /usr/lib/syslinux/ && \
  rm -rf syslinux-6.03

3. Build Bootable ISO Image

First, download the Linux kernel source code:

git clone --branch linux-6.12.y --depth 1 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
cd linux-stable

Configure the kernel with the smallest possible configuration:

make tinyconfig

This creates a minimal kernel configuration with the bare essentials needed to boot. It's perfect for creating a small ISO image, but may need additional features enabled depending on your hardware requirements.

Note: If you need to enable additional features after running tinyconfig, use:

make menuconfig    # Requires ncurses-dev package

Compile the Linux kernel and create the final ISO image using Make with the following configuration:

make isoimage \
  FDARGS="initrd=/initramfs.cpio.gz" \
  FDINITRD="../initramfs.cpio.gz" \
  ISOLINUX_BIN="/usr/lib/syslinux/isolinux.bin" \
  ARCH=x86_64 \
  CROSS_COMPILE=x86_64-linux-gnu- \
  -j 4

This command will:

  1. Build the Linux kernel with the specified architecture and compiler
  2. Package the kernel with the initramfs and bootloader into an ISO image

Component Details

Key Files

  • initramfs.cpio.gz: Initial RAM filesystem for system initialization
  • isolinux.bin: BIOS bootloader binary
  • ldlinux.c32: Core Syslinux module
  • vmlinuz: Compiled Linux kernel

Build Parameters

  • FDARGS: Kernel command line arguments
  • FDINITRD: Path to initramfs
  • ISOLINUX_BIN: Path to bootloader binary
  • ARCH: Target architecture
  • CROSS_COMPILE: Toolchain prefix
  • -j 4: Number of parallel build jobs