This repository documents the process of building a custom, lightweight Linux operating system using Buildroot.
This project was completed as part of the Operating Systems Laboratory course.
The primary goal of this project was to create a minimal, bootable Linux distribution from scratch.
This involved:
- Setting up a build environment
- Configuring the Linux kernel and root filesystem
- Compiling the sources
- Deploying the resulting image to a bootable USB drive
The development environment was set up on an Ubuntu 64-bit system running on VMware Workstation.
First, the system's package list was updated, and all installed packages were upgraded to their latest versions.
sudo apt update && sudo apt upgradeNext, essential packages and build tools required by Buildroot were installed.
sudo apt install build-essential binutils rsync wget libncurses-dev libelf-dev libssl-devThe core of this project involved using Buildroot to configure and build the custom Linux image.
Buildroot version 2025.02.3 was downloaded and extracted.
wget https://buildroot.org/downloads/buildroot-2025.02.3.tar.gz
tar -xf buildroot-2025.02.3.tar.gz
cd buildroot-2025.02.3The Buildroot configuration interface was launched using:
make menuconfigThe following key parameters were configured according to the project requirements:
- Target options: Set to
x86_64architecture - System configuration: Hostname set to
optional name, root password set to"optional name" - Target packages:
dropbear(an SSH server) selected - Filesystem images: Generate an
ext4root filesystem with a size of 120M - Bootloader:
grub2with support forx86-64-efi
These configurations were saved to the .config file.
The build process was initiated with:
makeThis step cross-compiles the toolchain, kernel, bootloader, and all selected userspace packages.
Upon completion, the final images were located in the output/images directory.
The total size of the generated OS was 30MB.
After a successful build, the generated images were written to a USB drive to create a bootable device.
The target USB drive (identified as /dev/sdd) was partitioned with two primary partitions:
- Boot partition (FAT32) for the bootloader and kernel
- Root partition (ext4) for the root filesystem
The newly created partitions were formatted and mounted:
# Format the partitions
sudo mkfs.vfat -F32 /dev/sdd1
sudo mkfs.ext4 /dev/sdd2
# Mount the partitions
sudo mount /dev/sdd1 /mnt/efi
sudo mount /dev/sdd2 /mnt/rootThe compiled artifacts were copied to the appropriate partitions on the USB drive:
# Copy boot files
sudo cp output/images/bzImage /mnt/efi/boot/
sudo cp -r output/images/efi-part/* /mnt/efi/
# Copy root filesystem
sudo cp -a output/images/rootfs.ext4 /mnt/root/The GRUB configuration file (grub.cfg) was modified to point to the correct root partition (/dev/sda2 instead of /dev/sda1).
Finally, the target laptop's BIOS settings were adjusted to boot from the USB drive.
- Secure Boot was disabled to allow the custom-signed OS to load
- Upon booting, the system successfully loaded the custom Linux OS
Login credentials:
- Username: root
- Password: shabnam
The process was not without its difficulties:
-
Insufficient Memory
The initial build failed due to insufficient memory allocated to the virtual machine.
Solution: Increased VM's disk space to 40GB. -
USB Detection Issues
The virtual machine repeatedly failed to recognize the USB drive.
Solution: Multiple troubleshooting attempts until the issue was resolved.