|
| 1 | +# Simple GUI-Based Linux Distro Creation Guide |
| 2 | + |
| 3 | +This guide will walk you through creating a simple graphical Linux distribution based on BusyBox and Nano-X, adapted to run on QEMU. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +Ensure you have a Debian-based system and install the necessary dependencies: |
| 8 | + |
| 9 | +```sh |
| 10 | +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 |
| 11 | +``` |
| 12 | + |
| 13 | +## Step-by-Step Instructions |
| 14 | + |
| 15 | +### 1. Download and Prepare the Linux Kernel |
| 16 | + |
| 17 | +1. **Download the Linux Kernel:** |
| 18 | + |
| 19 | + ```sh |
| 20 | + wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.9.4.tar.xz |
| 21 | + ``` |
| 22 | + |
| 23 | +2. **Extract the Kernel:** |
| 24 | + |
| 25 | + ```sh |
| 26 | + tar xf linux-6.9.4.tar.xz |
| 27 | + cd linux-6.9.4 |
| 28 | + ``` |
| 29 | + |
| 30 | +3. **Configure the Kernel:** |
| 31 | + |
| 32 | + ```sh |
| 33 | + make menuconfig |
| 34 | + ``` |
| 35 | + |
| 36 | +4. **Compile the Kernel:** |
| 37 | + |
| 38 | + ```sh |
| 39 | + make -j 4 |
| 40 | + ``` |
| 41 | + |
| 42 | +5. **Create a Directory for the Distro:** |
| 43 | + ```sh |
| 44 | + mkdir /distro |
| 45 | + cp arch/x86/boot/bzImage /distro/ |
| 46 | + ``` |
| 47 | + |
| 48 | +### 2. Set Up BusyBox |
| 49 | + |
| 50 | +1. **Download BusyBox:** |
| 51 | + |
| 52 | + ```sh |
| 53 | + cd ~ |
| 54 | + wget https://busybox.net/downloads/busybox-1.36.1.tar.bz2 |
| 55 | + ``` |
| 56 | + |
| 57 | +2. **Extract BusyBox:** |
| 58 | + |
| 59 | + ```sh |
| 60 | + tar xf busybox-1.36.1.tar.bz2 |
| 61 | + cd busybox-1.36.1 |
| 62 | + ``` |
| 63 | + |
| 64 | +3. **Configure BusyBox:** |
| 65 | + |
| 66 | + ```sh |
| 67 | + make menuconfig |
| 68 | + ``` |
| 69 | + |
| 70 | +4. **Compile and Install BusyBox:** |
| 71 | + ```sh |
| 72 | + make -j 4 |
| 73 | + make CONFIG_PREFIX=/distro install |
| 74 | + ``` |
| 75 | + |
| 76 | +### 3. Set Up MicroWindows |
| 77 | + |
| 78 | +1. **Clone MicroWindows:** |
| 79 | + |
| 80 | + ```sh |
| 81 | + git clone https://github.com/ghaerr/microwindows |
| 82 | + cd microwindows/src/ |
| 83 | + ``` |
| 84 | + |
| 85 | +2. **Configure MicroWindows:** |
| 86 | + |
| 87 | + ```sh |
| 88 | + cp Configs/config.linux-fb config |
| 89 | + nano config |
| 90 | + ``` |
| 91 | + |
| 92 | +3. **Compile MicroWindows:** |
| 93 | + |
| 94 | + ```sh |
| 95 | + make -j 4 |
| 96 | + make install |
| 97 | + make x11-demo |
| 98 | + ``` |
| 99 | + |
| 100 | +4. **Set Up a Sample GUI Application:** |
| 101 | + |
| 102 | + ```sh |
| 103 | + mkdir x11-demo |
| 104 | + cd x11-demo/ |
| 105 | + nano gui.c |
| 106 | + ``` |
| 107 | + |
| 108 | +5. **Compile the GUI Application:** |
| 109 | + ```sh |
| 110 | + cd .. |
| 111 | + mv x11-demo /distro/ |
| 112 | + cd /distro/x11-demo/ |
| 113 | + gcc gui.c -lNX11 -lnano-X -I /microwindows/src/nx11/X11-local/ |
| 114 | + mv a.out /distro/nirs-test-app |
| 115 | + ``` |
| 116 | + |
| 117 | +### 4. Prepare the Distro Environment |
| 118 | + |
| 119 | +1. **Create Necessary Directories:** |
| 120 | + |
| 121 | + ```sh |
| 122 | + mkdir -p /distro/lib/x86_64-linux-gnu/ |
| 123 | + mkdir /distro/lib64 |
| 124 | + ``` |
| 125 | + |
| 126 | +2. **Copy Required Libraries:** |
| 127 | + |
| 128 | + ```sh |
| 129 | + cp /lib/x86_64-linux-gnu/libpng16.so.16 /distro/lib/x86_64-linux-gnu/libpng16.so.16 |
| 130 | + cp /lib/x86_64-linux-gnu/libz.so.1 /distro/lib/x86_64-linux-gnu/libz.so.1 |
| 131 | + cp /lib/x86_64-linux-gnu/libfreetype.so.6 /distro/lib/x86_64-linux-gnu/libfreetype.so.6 |
| 132 | + cp /lib/x86_64-linux-gnu/libc.so.6 /distro/lib/x86_64-linux-gnu/libc.so.6 |
| 133 | + cp /lib/x86_64-linux-gnu/libm.so.6 /distro/lib/x86_64-linux-gnu/libm.so.6 |
| 134 | + cp /lib/x86_64-linux-gnu/libbrotlidec.so.1 /distro/lib/x86_64-linux-gnu/libbrotlidec.so.1 |
| 135 | + cp /lib64/ld-linux-x86-64.so.2 /distro/lib64/ld-linux-x86-64.so.2 |
| 136 | + cp /lib/x86_64-linux-gnu/libbrotlicommon.so.1 /distro/lib/x86_64-linux-gnu/libbrotlicommon.so.1 |
| 137 | + ``` |
| 138 | + |
| 139 | +3. **Copy Nano-X Binaries:** |
| 140 | + ```sh |
| 141 | + cp -r /microwindows/src/bin /distro/nanox |
| 142 | + cp /microwindows/src/runapp /distro/nanox/ |
| 143 | + ``` |
| 144 | + |
| 145 | +### 5. Create the Bootable Image |
| 146 | + |
| 147 | +1. **Create and Format the Image:** |
| 148 | + |
| 149 | + ```sh |
| 150 | + cd /distro/ |
| 151 | + truncate -s 200MB boot.img |
| 152 | + mkfs boot.img |
| 153 | + mkdir mnt |
| 154 | + mount boot.img mnt |
| 155 | + ``` |
| 156 | + |
| 157 | +2. **Install Extlinux:** |
| 158 | + |
| 159 | + ```sh |
| 160 | + extlinux -i mnt/ |
| 161 | + ``` |
| 162 | + |
| 163 | +3. **Copy Files to the Image:** |
| 164 | + |
| 165 | + ```sh |
| 166 | + mv bin bzImage lib lib64 linuxrc nanox nirs-test-app sbin usr mnt |
| 167 | + ``` |
| 168 | + |
| 169 | +4. **Create Additional Directories:** |
| 170 | + |
| 171 | + ```sh |
| 172 | + cd mnt/ |
| 173 | + mkdir var etc root dev tmp proc |
| 174 | + ``` |
| 175 | + |
| 176 | +5. **Unmount the Image:** |
| 177 | + ```sh |
| 178 | + cd .. |
| 179 | + umount mnt |
| 180 | + ``` |
| 181 | + |
| 182 | +### Links |
| 183 | + |
| 184 | +- [Linux Kernel](https://www.kernel.org/) |
| 185 | +- [BusyBox](https://busybox.net/) |
| 186 | +- [MicroWindows](https://github.com/ghaerr/microwindows) |
| 187 | +- [X11 Hello](https://gist.github.com/nir9/098d83c7...) |
| 188 | + |
| 189 | +With these steps, you will have created a simple graphical Linux distribution ready to run on QEMU. |
| 190 | + |
| 191 | +<!-- https://www.youtube.com/watch?v=guSDz5Iwgw0&t=3s --> |
0 commit comments