Dependency-free, suckless bootable disk image creator

bzt 9ea004550e Updated binaries 1 ano atrás
distrib 9ea004550e Updated binaries 1 ano atrás
docs b66e2f54be Refactored image creator 1 ano atrás
example b66e2f54be Refactored image creator 1 ano atrás
src 9ea004550e Updated binaries 1 ano atrás
.gitignore 3dd3d9440c Code cleanup 1 ano atrás
LICENSE 4ac11b2aab Initial commit 1 ano atrás
README.md b66e2f54be Refactored image creator 1 ano atrás
simpleboot.h 6b84aeba36 Added license's name too not just the terms of use 1 ano atrás

README.md

Simpleboot

Simpleboot is an all-in-one OS loader and bootable disk image creator that can load Linux kernels and Multiboot2 compliant kernels in ELF and PE formats.

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away."

Antoine de Saint-Exupéry

This loader is a single file, as small as 52k, and yet it supports multiple firmware (like BIOS, UEFI), multiple file formats (ELF, PE), multiple ABIs (SysV, fastcall, CDECL), multiple architectures (i386, x86_64; there's also an AArch64 variant for Raspberry Pi), multiple boot protocols (Linux boot, Multiboot2, capable to fallback to FreeBSD or BIOS boot partitions), even transparently uncompresses your payloads and generates ACPI tables on platforms that do not support it natively. It's probably the winner by far in "the most features per byte in a boot loader" category. And yes, you can relax, it can also display a custom boot logo for you.

Rationale

I was wondering what could be the bare minimum and simplest usable implementation of booting a kernel, because let's face it, GRUB and the others sucks big time. They're very overcomplicated, bloated, hard to install and very easy to fuck up their config syntax. And all the helpers (like grub-mkrescue or syslinux) have an outrageous number of dependencies, each with its own unnecessary hazard of version incompatibility or possibly missing commands. To be honest, I never understood why creating a disk image file has to be more complicated than creating a zip or tar archive for example.

There's definitely a need for a much simpler, much easier to use and much more user friendlier solution than GRUB. The typical usecase is OS installer image creation, 99% of end-user computers with just one OS, and especially hobby OS development. In all these cases there's absolutely no need for a complicated and interactive boot manager, because there's only one kernel to boot, and with the last case it is very important that you should be able to rapidly and quickly create and test run new images without a fuzz. So just because I can, I've created such a suckless tool, here's my solution:

  1. create a directory and put your files in it, among other things your kernel binary
  2. execute the dependency-free simpleboot (source directory) (output image file) command
  3. and... that's about it... nothing else left to do! The image Just Works (TM), it will get your kernel booted!

You can install the loader and make an existing device or image bootable; or you can create a bootable image anew. You can boot that image in a VM, or you can write it with dd or USBImager to a storage and boot that on a real machine too.

Simplicity is the ultimate sophistication! The name Simpleboot is a pun on Multiboot because it uses a saner, simpler (yet compatible) subset of the boot protocol and has a much simpler tool usage.

NOTE: The Multiboot2 protocol is just too dumb to handle SMP, therefore we can't do that (the protocol doesn't allow higher-half kernels either, but I've found a way to support those without violating the protocol too much). If you want a clean way to boot your higher-half kernel on all available CPU cores without any dirty hacks, then I strongly recommend to try out BOOTBOOT instead.

Installation

Just download the binary for your OS. These are portable executables, they don't require installation and they don't need any shared libraries / DLLs.

Furthermore you can find various packaging solutions in the distrib directory (for Debian, Ubuntu, RaspiOS, Gentoo, Arch).

Compilation

GNU/make needed for orchestration (although it's literally just cc simpleboot.c -o simpleboot). The toolchain doesn't matter, any ANSI C compiler will do, works on POSIX and WIN32 MINGW too. Just go to the src directory and run make. That's all. Despite of it's small size, it is self-contained and has exactly zero library dependencies. It's not called Simpleboot for nothing :-)

To recompile the "boot_x86.bin" sector, you'll need the flatassembler, and for the "loader_x86.efi" and "loader_rpi.bin" you'll have to install LLVM Clang and lld (gcc and GNU ld won't work I'm afraid). But don't worry, I've added all three to src/data.h as a byte array, so you don't have to compile these unless you really really want to (for that, just delete data.h before you run make).

Documentation

The detailed documentation on how to use the bootable disk creator and how a kernel is booted can be found in the docs directory. It includes all the relevant parts of the Multiboot2 specification too (a fixed version that matches what's actually in GRUB's multiboot2.h header).

Example Kernels

In the example directory, you can find very simple "kernels", these just dump the received boot parameters to the serial console. The kernel.c is more or less the same as the Multiboot2 example kernel (just uses the simpleboot.h header with typedefs and has serial output instead of VGA text mode). Note that NO ASSEMBLY prologue nor any special embedded data required with Simpleboot. The linux.c is just a Linux kernel mock up for testing the boot parameters passing.

License

Licensed under the permissive terms of the MIT license, see LICENSE file for details. Do as you please. Not required, but attribution appreciated.

Contributors

I'd like to say thanks to Zahy for valuable feedback on FreeBSD. Special thanks to dzsolt for providing the ebuild.

Social

Sorry, I don't use facepalm, twitees, masturbadon, vector, discoss and alike. I don't use anything that forces shady JS on users (and that's why this repo isn't stored on github, btw).

Cheers,

bzt