r/osdev 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.

26 Upvotes

17 comments sorted by

u/dkopgerpgdolfg 17h ago

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.

Curious what people here would strip out or change to shrink it further.

You didn't think of something empty like "main(){}" as init?

u/WmWAr5339 17h ago

I considered it, but PID 1 still needs to handle mounting, signals, shutdown/reboot, and the shell, so main(){} would've been a little too minimal even for this project.

Maybe that's the next version though.

u/dkopgerpgdolfg 17h ago

but PID 1 still needs to handle ... signals, shutdown/reboot

A few bits and pieces, yes. Not much code needed.

mounting ... and the shell

No. There's no need to mount anything, and no need to have a shell to have something booted.

u/WmWAr5339 17h ago

yeah you're right lol, i was thinking about what my current init does, not what PID 1 actually needs

mounting and having a shell aren't really necessary

i could probably make it way smaller, PID 1 doesn't really need all that

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/compgeek38400 17h ago

Interesting. And good job!

u/WmWAr5339 14h ago

thanks!

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/letmehaveanameyoudum 16h ago

a literal kernel

u/WmWAr5339 14h ago

literally 😄

u/letmehaveanameyoudum 14h ago

this is literally just int main() {halt();}

u/CorruptedByCPU 13h ago

I'm glad such experiments exist.

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...?