Login
You're viewing the y.diskcat.com public feed.
  • Mar 27, 2025, 11:06 AM

    I wonder if 1.44M are enough for a modern Linux kernel, one (1) NIC driver, BusyBox, Wireguard and nftables for a teeny tiny basic router OS. Hmm :neocat_think:

    💬 2🔄 0⭐ 2

Replies

  • Mar 28, 2025, 9:56 AM

    Well, I'm currently at about 18k free space of 1.44M and have a kernel+initramfs that can talk to RTL8139C NICs, do DHCP client *and* server duties, brings up a Wireguard tunnel succesfully and a static iptables binary that runs, but complains about missing extensions for targets like MASQUERADE. If anyone seeing this post knows how to tell iptables during configure/make how to include extensions when building statically, please, do tell!

    nftables was too ambitious to include at ~700KB

    💬 1🔄 4⭐ 5
  • Mar 29, 2025, 5:25 AM

    Hah, figured it out, albeit in a messy way: Passing "--enable-static --disable-shared" builds a fully static iptables binary with all extensions included, which turns out way too big of a binary. However, one can just remove unneeded extension source files from the extensions directory in the iptables sources and iptables builds happily without them.

    Switching to a i486-linux-musl toolchain also brought the free space up to 35 whole kilobytes! Whoa! Maybe enough for a simple web UI with httpd?

    💬 1🔄 0⭐ 1
  • Mar 29, 2025, 5:27 AM

    I also managed to squeeze telnetd in, for remote managing the "router". Maybe I'll use that extra free space for second NIC driver. Or perhaps I can shove FAT and block device support in, so the configuration files on the floppy can actually be edited and saved instead of being baked into the initramfs! So many options!

    💬 1🔄 0⭐ 1
  • Mar 29, 2025, 5:45 AM

    And yup, it boots, at least in QEMU. Emulated 486DX CPU, 16MB of RAM and a standard 1.44M floppy disk image, booted with this lovely tiny-floppy-bootloader project: github.com/guineawheek/tiny-fl

    Unfortunately, it errors out in 86box upon calling interrupt 0x15 after enabling the A20 line (?), which, as far as I could find out, has something to do with the lack of a memory size reporting instruction in protected mode in BIOSes, which just wasn't a standardized thing before the 2000s or something? Hmpf

    Screenshot of a terminal window showing the output of "ip addr show", which reports information about the loopback interface, two ethernet interfaces with IP addresses assigned and a Wireguard interface. Followed by that command is the output of "wg show", which shows an active Wireguard connection, followed by the first few lines of "cat /proc/cpuinfo", showing this Linux system runs on an emulated Intel 486DX/4
    💬 1🔄 0⭐ 2
  • 💬 0🔄 0⭐ 0
  • Mar 27, 2025, 1:19 PM

    @snep That would be a really fun challenge. 1.44MiB is not a lot for a modern Linux kernel alone already. If you want to tinker OpenWrt might have some interesting patches to reduce kernel size

    💬 1🔄 0⭐ 1
  • Mar 28, 2025, 4:23 AM

    @Toble_Miner I'm currently trying with a bare kernel and a hand-assembled BusyBox initramfs, though a minimum viable kernel with nothing but script and binary execution enabled and the console on ttyS0, compressed with LZMA (the most effective it seems) is already nearly 700k, not leaving alot of space for adding net support, PCI NIC modules, netfilter and all required user space programs and libraries :neocat_laugh_sweat:

    I might take a peek at how OpenWRT configures their X86 kernel!

    💬 1🔄 0⭐ 0
  • Apr 1, 2025, 1:33 AM

    @snep @Toble_Miner i suspect compiling the NIC drivers in kernel will use less disk space than the modules themselves.

    Plus you can omit commands for managing modules.

    💬 1🔄 0⭐ 1
  • Apr 1, 2025, 5:58 AM

    @drscriptt @Toble_Miner Oh that's what I did, yeah, I knew including loadable module support would not only make the kernel bigger but also potentially the embedded initramfs archive, if modules were included in it.
    Pretty sure right now I'm getting such a solid XZ compression of both kernel and initramfs due to there being a lot of shared code in each one respectively, modules and the kernel in the bzImage and a lot of similar chunks in the statically compiled+stripped binaries in the initramfs

    💬 1🔄 0⭐ 1
  • Apr 1, 2025, 6:02 AM

    @drscriptt @Toble_Miner In the end, I did actually squeeze a working iptables binary in there, even if it pretty much only does the bare basics + CONNTRACK and NAT extensions, a wg binary plus included kernel module for Wireguard tunnels and bunch of BusyBox applets, mostly for networking like udhcpc/d, ip commands and telnet, currently with still ~20k free! I'd call it a successful experiment :neocat_blep:

    💬 1🔄 0⭐ 2
  • 💬 0🔄 0⭐ 1