Operations 9 min read

How to Build Your Own Minimal Linux System from Scratch

This step‑by‑step guide explains how to create a custom minimal Linux system by adding a new disk, partitioning it, installing GRUB, copying kernel and initramfs files, configuring boot scripts, and enabling network functionality, complete with detailed commands and screenshots.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Build Your Own Minimal Linux System from Scratch

Introduction

Since Linux was created on October 5, 1991, its open‑source nature has attracted many developers who contribute to the kernel and related software, providing a rich environment for learning and research.

This article shows how to trim an existing Linux system to build a personal mini‑Linux with common functions.

Principle

Before creating the mini‑system, it is useful to understand the Linux boot process:

POST self‑test checks hardware for faults.

If multiple boot disks exist, select the boot disk in BIOS.

The bootloader in the MBR is executed.

The kernel image is loaded.

The init process (the ancestor of all processes) runs.

A welcome screen is displayed.

During kernel loading, two auxiliary files are needed:

initrd – a memory‑based disk used in CentOS 5.

initramfs – a memory‑based filesystem used in CentOS 6.

The init system reads /etc/inittab and then runs the system‑initialization script /etc/rc.d/rc.sysinit.

Idea

1. Add a new hard disk /dev/sdb to an existing Linux host, create two partitions ( /boot and /), and format them. After setup, the disk will be moved to a new machine and become /dev/sda.

2. On /dev/sdb build an independent Linux system, copying files one by by one and installing the GRUB bootloader.

3. Copy the kernel and initramfs files to the new disk, as they are essential for a bootable system.

4. Use a script (provided later) to copy necessary utilities.

5. After completing these steps, the custom Linux system is ready.

Procedure

We use CentOS 6.9 as the example.

1. Disk partitioning

Attach a 20 GB disk to the host.

Use fdisk to partition /dev/sdb.

Format the partitions and create a mount point /mnt/boot.

2. Install GRUB

Run grub-install --root-directory=/mnt to install the second‑stage GRUB files.

Verify the installation by checking the binary.

Installation succeeded.

3. Copy kernel and initrd

Copy the kernel image and initrd to /mnt/boot.

4. Create grub.conf

Write a grub.conf file based on the kernel version, disable SELinux, and set the init parameter to avoid errors.

5. Create directories and copy files

Create the root directory, mount /dev/sdb2 to /mnt/sysroot, and copy essential utilities (ls, ifconfig, bash, reboot, rm, modprobe, mount, ip, mkdir, touch, cat, vi, less, shutdown, insmod) via a script.

Verification shows all utilities were copied successfully.

Script source code for copying commands is provided (image omitted).

6. Copy network driver

Query network card details, then copy the driver modules into /mnt/sysroot libraries.

All operations are now complete; the disk can be removed, attached to a new virtual machine, and powered on.

Boot Test

Create a new VM, replace its default disk with the custom one, and start it.

The VM boots successfully, confirming the experiment.

Enable Network Functionality

Copy the network driver modules into the new system’s library path and configure the network.

After adding the driver, ping the assigned IP address from another machine; the ping succeeds.

With networking working, the custom Linux system is fully operational.

All experiments completed successfully!

LinuxbootloadergrubInitramfscustom distro
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.