<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: mango6612xxx</title>
    <description>The latest articles on DEV Community by mango6612xxx (@mango6612xxx_405b399c9ee7).</description>
    <link>https://dev.to/mango6612xxx_405b399c9ee7</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4271821%2Ff2e11f1e-713a-4b73-b629-30bdb2b416bf.png</url>
      <title>DEV Community: mango6612xxx</title>
      <link>https://dev.to/mango6612xxx_405b399c9ee7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mango6612xxx_405b399c9ee7"/>
    <language>en</language>
    <item>
      <title>Building minimal Linux with UKI boot</title>
      <dc:creator>mango6612xxx</dc:creator>
      <pubDate>Sun, 29 Nov 2026 07:00:17 +0000</pubDate>
      <link>https://dev.to/mango6612xxx_405b399c9ee7/building-minimal-linux-with-uki-boot-5do3</link>
      <guid>https://dev.to/mango6612xxx_405b399c9ee7/building-minimal-linux-with-uki-boot-5do3</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpo4xp2o76i3nfojm891i.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpo4xp2o76i3nfojm891i.webp" alt=" " width="732" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most Linux distros ship with GRUB or systemd-boot. But what if you could boot the kernel itself as an EFI executable, with no bootloader in between?&lt;/p&gt;

&lt;p&gt;In this article I'll show how I built &lt;strong&gt;crabOS&lt;/strong&gt; — a minimal Linux system that boots as a Unified Kernel Image (UKI), where the kernel + initramfs + cmdline are packed into one EFI binary.&lt;/p&gt;

&lt;h1&gt;
  
  
  The boot flow
&lt;/h1&gt;

&lt;p&gt;UEFI firmware → /EFI/BOOT/BOOTX64.EFI (kernel + initramfs + cmdline) → kernel boots, unpacks initramfs → /init runs, starts shell&lt;/p&gt;

&lt;p&gt;No GRUB, no systemd-boot, no intermediate bootloader. The kernel is the bootloader.&lt;/p&gt;

&lt;h1&gt;
  
  
  How UKI works
&lt;/h1&gt;

&lt;p&gt;A UKI is a PE/COFF executable (the same format as .exe on Windows) that contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Linux kernel (bzImage)&lt;/li&gt;
&lt;li&gt;The initramfs (cpio.gz)&lt;/li&gt;
&lt;li&gt;The kernel command line&lt;/li&gt;
&lt;li&gt;An OS release section (optional)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;UEFI firmware loads this as a regular EFI application, and the kernel boots itself.&lt;/p&gt;

&lt;h1&gt;
  
  
  Building the UKI
&lt;/h1&gt;

&lt;p&gt;I used ukify from systemd (or objcopy as a fallback):&lt;/p&gt;

&lt;p&gt;ukify build --linux=bzImage --initrd=initramfs.cpio.gz --cmdline="root=PARTUUID=4352424f-02 rootwait rw init=/init" --output=BOOTX64.EFI&lt;/p&gt;

&lt;p&gt;Then place it at /EFI/BOOT/BOOTX64.EFI on the ESP (FAT32 partition).&lt;/p&gt;

&lt;h2&gt;
  
  
  The catch: no command line from firmware
&lt;/h2&gt;

&lt;p&gt;When UEFI boots \EFI\BOOT\BOOTX64.EFI directly, it passes no command line. So root= must be built into the kernel via CONFIG_CMDLINE:&lt;/p&gt;

&lt;p&gt;CONFIG_CMDLINE_BOOL=y&lt;br&gt;
CONFIG_CMDLINE="root=PARTUUID=4352424f-02 rootwait rw init=/init"&lt;/p&gt;

&lt;p&gt;This works, but it's fragile — if you change the disk layout, you need to rebuild the kernel. A better approach would be to discover root by label/UUID from initramfs, or use a real bootloader. That's next on my roadmap.&lt;/p&gt;

&lt;h1&gt;
  
  
  The stack
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Kernel: Linux 6.18.65 (EFI stub enabled)&lt;/li&gt;
&lt;li&gt;libc: musl 1.2.6 (static toolchain)&lt;/li&gt;
&lt;li&gt;Userland: BusyBox 1.38.0, statically linked&lt;/li&gt;
&lt;li&gt;Installer: written in Go (static, CGO off)&lt;/li&gt;
&lt;li&gt;Packages: apk against Alpine v3.23 repos&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  What's inside the live system
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;UKI boot (kernel + initramfs + cmdline in one EFI binary)&lt;/li&gt;
&lt;li&gt;Go installer that writes MBR, creates ESP (FAT32) + ext2 root&lt;/li&gt;
&lt;li&gt;UTF-8 console with Cyrillic font and us/ru/ua layouts&lt;/li&gt;
&lt;li&gt;DHCP on boot, apk add htop works from the live ISO&lt;/li&gt;
&lt;li&gt;Experimental X11 via crab-x (starts Xorg on a real VT)&lt;/li&gt;
&lt;li&gt;~42 MB RAM after boot, ISO is 106 MB&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Try it in 30 seconds
&lt;/h1&gt;

&lt;p&gt;qemu-system-x86_64 -m 1G -cdrom crabos.iso -bios /usr/share/edk2/ovmf/OVMF_CODE.fd&lt;/p&gt;

&lt;p&gt;Or clone the repo and run ./run.sh — it sets up OVMF and a 4 GB test disk for you.&lt;/p&gt;

&lt;p&gt;VirtualBox: Linux 64-bit, ≥1 GB RAM, EFI enabled, Secure Boot off.&lt;/p&gt;

&lt;h1&gt;
  
  
  Build from source
&lt;/h1&gt;

&lt;p&gt;./build.sh         # kernel + musl + static BusyBox + initramfs&lt;br&gt;
./build-iso.sh     # hybrid ISO (UEFI; BIOS if isolinux is installed)&lt;br&gt;
./run.sh           # live boot in QEMU&lt;br&gt;
./run.sh disk      # boot the installed system via UEFI/OVMF&lt;/p&gt;

&lt;p&gt;Host deps (Fedora names): gcc make wget cpio tar flex bison bc perl, xorriso mtools dosfstools syslinux, systemd-ukify, qemu, kbd, terminus-fonts-console.&lt;/p&gt;

&lt;p&gt;Everything user-facing lives in overlay/, configs in configs/.&lt;/p&gt;

&lt;h1&gt;
  
  
  Honest limitations (0.1)
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;x86_64 + UEFI only; image is unsigned, Secure Boot must be off&lt;/li&gt;
&lt;li&gt;Tested in QEMU and VirtualBox only — no bare metal yet&lt;/li&gt;
&lt;li&gt;MBR partitioning: disks &amp;gt;2 TiB are partly wasted&lt;/li&gt;
&lt;li&gt;Whole-disk install, no dual boot&lt;/li&gt;
&lt;li&gt;Root PARTUUID is hardcoded in CONFIG_CMDLINE — first thing to fix in 0.2&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  What I learned
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;UKI boot is surprisingly simple — no GRUB config, no bootloader maintenance&lt;/li&gt;
&lt;li&gt;EFI stub kernels are the future for minimal systems&lt;/li&gt;
&lt;li&gt;The tradeoff: hardcoded CONFIG_CMDLINE is fragile, but good enough for 0.1&lt;/li&gt;
&lt;li&gt;Static BusyBox + musl gives you a ~42 MB RAM footprint after boot&lt;/li&gt;
&lt;li&gt;Writing the installer in Go was a good choice — static binary, no runtime deps&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Resources
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;ISO and GPL sources: &lt;a href="https://github.com/mango5512xxx-crypto/crabOS/releases" rel="noopener noreferrer"&gt;https://github.com/mango5512xxx-crypto/crabOS/releases&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Source code: &lt;a href="https://github.com/mango5512xxx-crypto/crabOS" rel="noopener noreferrer"&gt;https://github.com/mango5512xxx-crypto/crabOS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Verify ISO: sha256sum -c SHA256SUMS or gh attestation verify crabos.iso --repo mango5512xxx-crypto/crabOS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're building a minimal Linux or embedded system, UKI boot is worth exploring. No more "which bootloader do I use?" — the kernel is the bootloader.&lt;/p&gt;




&lt;p&gt;I'm the author of crabOS. This is a learning project — I wanted to understand the boot chain from kernel to initramfs without remastering someone else's work. Feedback welcome, especially on root discovery by label/UUID from initramfs vs using a real bootloader.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>infrastructure</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
