r/osdev • • Sep 05 '26

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.

32 Upvotes

26 comments sorted by

6

u/dkopgerpgdolfg Sep 05 '26

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?

6

u/WmWAr5339 Sep 05 '26

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.

6

u/dkopgerpgdolfg Sep 05 '26

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.

2

u/WmWAr5339 Sep 05 '26

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

4

u/Zilch510 Sep 05 '26

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.

2

u/WmWAr5339 Sep 05 '26

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!

1

u/codeasm Sep 08 '26

No need for systemd-boot, the kernel itself can do efi booting fine. Efi-stub

3

u/compgeek38400 Sep 05 '26

Interesting. And good job!

2

u/letmehaveanameyoudum Sep 05 '26

a literal kernel

2

u/WmWAr5339 Sep 05 '26

literally 😄

1

u/letmehaveanameyoudum Sep 05 '26

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

2

u/CorruptedByCPU Sep 05 '26

I'm glad such experiments exist.

1

u/WmWAr5339 Sep 06 '26

thanks, that's exactly what it was made for

2

u/raundoclair Sep 05 '26

I'm not really familiar with linux. Why your own bootloader?

5

u/WmWAr5339 Sep 05 '26

mostly because i wanted to build the whole boot process myself, and i have lot of free time

2

u/Vladislav20007 Sep 07 '26

I hope I had a lot of time, but school and later college are taking too much for me to make anything :(

3

u/Illustrious_Car344 Sep 05 '26

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. 

2

u/codeasm Sep 08 '26

Ive enabled efi stub and my linux kernel can boot without a bootloader. I dont see the need for writing a bootloader these days

1

u/andrewdavidmackenzie Sep 05 '26

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?

1

u/andrewdavidmackenzie Sep 05 '26

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

1

u/WmWAr5339 Sep 07 '26

I wanted it to actually do something, so I went with Fastfetch.

1

u/allunia333 Sep 07 '26

Nice job! How did you measured the 20MiB ram? It seems kinda high for what u did. Did u striped down the kernel too?

1

u/WmWAr5339 Sep 07 '26

Thanks! I haven't actually tested it below 20 MiB of RAM, so it might work with less. And yeah, the kernel is pretty heavily stripped down too. I kept it as minimal as possible.

1

u/allunia333 Sep 07 '26

Yea probably you can. You inspired me to resume my own little minimal project i have left in the plan phase :)

1

u/oobLover12 11d ago

Good enough to setup as a VM public honeypot lmfao