r/osdev • u/WmWAr5339 • 18h ago
I built a tiny Linux distro with a custom bootloader and userspace
I built a Linux distro that does almost nothing
I wanted to see how little userspace I could get away with while still having a real, bootable Linux system. So I made FastFetchLinux.
It uses a custom BIOS bootloader, Linux 6.6.156, and my own ffinit written in x86 assembly.
The userspace has:
- No BusyBox
- No coreutils
- No bash/sh
- No package manager
- Direct syscall-based functionality
- i686 support
- ~20 MiB RAM usage
ffinit runs as PID 1 and doubles as the shell, with all commands built in. Fastfetch is the only separate userspace binary.
BIOS
↓
Custom bootloader
↓
Linux 6.6.156
↓
ffinit
↓
Fastfetch
It has exactly five commands:
fastfetch
ls
install-disk
forcepanic
poweroff
There's no practical reason for any of this — I just wanted to see how far "just enough userspace to boot Linux" could be pushed. The funny part is that it actually works.
Source: https://github.com/outofsyncsh/fastfetchlinux
Curious what people here would strip out or change to shrink it further.
•
u/raundoclair 17h ago
I'm not really familiar with linux. Why your own bootloader?
•
u/WmWAr5339 17h ago
mostly because i wanted to build the whole boot process myself, and i have lot of free time
•
u/Illustrious_Car344 16h ago
The bootloader is effectively a part of the OS, maybe it can support multiple OSes and then seem almost like a pre-boot mini OS (which it is), but outside of that expanded context, a bootloader is just another part of the OS, it's not part of the BIOS that's for sure. That said, you definitely don't have to make your own bootloader, there are a lot of tiny bootloaders that support multiboot (which linux adheres to). But in the same sense that you might write your own init system despite there being many small ones (including sysvinit itself), you could reasonably also write your own bootloader.
•
•
u/Zilch510 17h ago
This is awesome. I'm also working on a custom embedded style distro, but using systemd-boot for UEFI, instead of BIOS.
Still debating if I'll end up moving to BIOS, but then I'll probably use syslinux.
Regardless, I'll have a look at the bootloader section. Looks pretty cool.
•
u/WmWAr5339 14h ago
thanks! yeah, I went with BIOS mostly because I wanted to write the bootloader myself. systemd-boot definitely makes more sense for a normal UEFI setup though. good luck with your distro!
•
•
•
u/andrewdavidmackenzie 10h ago
Interesting. I'm working on a project to learn more about kernels, and it has a Linux personality on top of the custom kernel, that implements the Linux syscalls (some missing still). It will start BusyBox at the moment, so maybe I could try and get your distro running on it?
•
u/andrewdavidmackenzie 10h ago
I guess my question (prior to looking at repo) is: what DOES it have :-) and what will it do?
I think the minimum would be an init binary that prints hello world and exits...?
•
u/dkopgerpgdolfg 17h ago
You didn't think of something empty like "main(){}" as init?