This guide will walk you through creating a simple graphical Linux distribution based on BusyBox and Nano-X, adapted to run on QEMU.
Ensure you have a Debian-based system and install the necessary dependencies:
sudo apt update && sudo apt install wget bzip2 libncurses-dev flex bison bc libelf-dev libssl-dev xz-utils autoconf gcc make libtool git vim libpng-dev libfreetype-dev g++ extlinux nano
-
Download the Linux Kernel:
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.9.4.tar.xz
-
Extract the Kernel:
tar xf linux-6.9.4.tar.xz cd linux-6.9.4
-
Configure the Kernel:
make menuconfig
-
Compile the Kernel:
make -j 4
-
Create a Directory for the Distro:
mkdir /distro cp arch/x86/boot/bzImage /distro/
-
Download BusyBox:
cd ~ wget https://busybox.net/downloads/busybox-1.36.1.tar.bz2
-
Extract BusyBox:
tar xf busybox-1.36.1.tar.bz2 cd busybox-1.36.1
-
Configure BusyBox:
make menuconfig
-
Compile and Install BusyBox:
make -j 4 make CONFIG_PREFIX=/distro install
-
Clone MicroWindows:
git clone https://github.com/ghaerr/microwindows cd microwindows/src/
-
Configure MicroWindows:
cp Configs/config.linux-fb config nano config
-
Compile MicroWindows:
make -j 4 make install make x11-demo
-
Set Up a Sample GUI Application:
mkdir x11-demo cd x11-demo/ nano gui.c
-
Compile the GUI Application:
cd .. mv x11-demo /distro/ cd /distro/x11-demo/ gcc gui.c -lNX11 -lnano-X -I /microwindows/src/nx11/X11-local/ mv a.out /distro/nirs-test-app
-
Create Necessary Directories:
mkdir -p /distro/lib/x86_64-linux-gnu/ mkdir /distro/lib64
-
Copy Required Libraries:
cp /lib/x86_64-linux-gnu/libpng16.so.16 /distro/lib/x86_64-linux-gnu/libpng16.so.16 cp /lib/x86_64-linux-gnu/libz.so.1 /distro/lib/x86_64-linux-gnu/libz.so.1 cp /lib/x86_64-linux-gnu/libfreetype.so.6 /distro/lib/x86_64-linux-gnu/libfreetype.so.6 cp /lib/x86_64-linux-gnu/libc.so.6 /distro/lib/x86_64-linux-gnu/libc.so.6 cp /lib/x86_64-linux-gnu/libm.so.6 /distro/lib/x86_64-linux-gnu/libm.so.6 cp /lib/x86_64-linux-gnu/libbrotlidec.so.1 /distro/lib/x86_64-linux-gnu/libbrotlidec.so.1 cp /lib64/ld-linux-x86-64.so.2 /distro/lib64/ld-linux-x86-64.so.2 cp /lib/x86_64-linux-gnu/libbrotlicommon.so.1 /distro/lib/x86_64-linux-gnu/libbrotlicommon.so.1
-
Copy Nano-X Binaries:
cp -r /microwindows/src/bin /distro/nanox cp /microwindows/src/runapp /distro/nanox/
-
Create and Format the Image:
cd /distro/ truncate -s 200MB boot.img mkfs boot.img mkdir mnt mount boot.img mnt
-
Install Extlinux:
extlinux -i mnt/
-
Copy Files to the Image:
mv bin bzImage lib lib64 linuxrc nanox nirs-test-app sbin usr mnt
-
Create Additional Directories:
cd mnt/ mkdir var etc root dev tmp proc
-
Unmount the Image:
cd .. umount mnt
With these steps, you will have created a simple graphical Linux distribution ready to run on QEMU.