Hacker News new | past | comments | ask | show | jobs | submit login
Busybox-based Linux distro from scratch (re-ws.pl)
181 points by pfrog 51 days ago | hide | past | favorite | 26 comments



Nice to see a version of this process for an UEFI kernel. ~2 years ago I was playing around with a similar LFS like, home made DIY distro myself which runs on an i586 router board and a Raspberry Pi.

Sadly this guide skips all the "fun parts" of bootstrapping your own compiler toolchain first, and instead downloads a pre-built one from a third party.

Based on my project, I also decided to write a small guide similar to this one, for the Raspberry Pi 3 as a target[1], but also included the toolchain bootstrapping process[2].

[1] https://github.com/AgentD/diy-linux-guide

[2] https://github.com/AgentD/diy-linux-guide/blob/master/crossc...


I agree, you learn a lot doing this! I cut my teeth on portable build systems after cross-compiling a bootstrap toolchain for SH4 CPUs so I could build a Linux distro for my Dreamcast. Way more fun working on an unusual platform and building it from scratch.


Hahaha. I did that too based on the LinuxDevices article. I even had a few conversations with the author.

https://linuxdevices.org/turning-the-sega-dreamcast-into-a-l...


Not sure of practical applications with super-cheap sizeable flash storage available everywhere, but it's nice to know you can still build a bootable Linux system entirely from scratch using simple instructions with latest kernels.

I might just give it a try for shits and giggles; I remember trying "Linux From Scratch" a decade or so ago and it took hours / days to get to a "bootable" state.


Getting a bootable system is quite easy actually. Build a kernel, build a static busybox, install grub. Thats almost it. Maybe build iw and wpa_supplicant, if you want wireless. You can get to a bootable system within an hour or so.

But anything beyond that is a maze of vaguely specified dependencies. LFS was a good starting point, but i havent checked it for a while and I'm not sure it kept up with all the recent(ish) developments in distro building.


LFS is kept up to date. It has systemd and sysvinit variants, and the latest version was published in september. Thank god for this, because it's one of the only source to get a comprehensive list of all the components running on a Linux machine.


If you're booting from UEFI you don't even need GRUB. You can make the kernel a UEFI app, register it, and then just select it from the BIOS list (or whatever we're calling that "Press F8 during bootup" thing now)


"Maybe some people know, some does not, that Linux is itself a boot loader of some kind. At least, when using UEFI and this is what I want to use, it can be loaded directly by UEFI firmware. [...] it won’t be as simple as that, for legacy BIOS."

Hmm I remember it being that easy back in the early 2000s. IIRC it was enough to copy the kernel to a floppy disk and have it boot. Well, back then the Kernel and Busybox fit easily on a single 1.5MB disk...


Many years ago I ran muLinux (http://www.linfo.org/mulinux) on an old desktop that I was gifted.

It was surprisingly capable for being so tiny and eventually led me to install Slackware (https://en.wikipedia.org/wiki/Slackware) on a better machine that had a CD-ROM drive.


There still was a tiny bootloader happening on that floppy. I /think/ back then it was still lilo (slackware boot floppies) OR syslinux bootloaders


I'm relatively sure it worked without lilo (but that's so long ago I might be wrong).

This stackoverflow question suggests support for this was explicitly dropped from the linux kernel: https://superuser.com/questions/415429/how-to-boot-linux-ker...


Yep, you had to modify the kernel to set some options so that it would know what device held the initrd (and where on the disk), and then you could dd that to the floppy and dd the initrd after it. At boot time the BIOS would load the kernel from the floopy, Linux would open the fd device, adjust the device to seek to the beginning of the initrd, mount the initrd, then load and execute init.

But the later convention was to create a loopback device tied to a disk image, mkfs.minix it, mount it, copy the kernel and an initrd, and run lilo on the loopback device. Then unmount and decouple the loopback from the disk image and dd that to the floppy. It didn't really take up any extra space and made it easier to update your initrd or kernel.


The BIOS only loads a 512 byte sector, never a whole kernel. So if you want to directly boot a zImage, the first 512 bytes of the zImage would need to implement floppy sector reading loops to load the rest of the kernel block by block.


I think you're right, it could be I used uncompressed kernels for the first example (it's been a few years...)


KISS Linux[1] is a similar option. Busybox-based init and coreutils (with musl by default), although all shell scripts are POSIX compliant so you can plug in pretty much whatever you want (sbase/ubase, GNU's coreutils, etc).

[1] https://k1ss.org


I would think 16MB is quite big considering how small Linux will let you go. I used to make 17MB images with NetBSD without any effort toward reducing size.


Useful compressed x86_64 kernel (trimmed down config to contain only the modules that are normally loaded on my system - only built-in) is about 11MiB.

On one of my less-featured ARM boards zImage can get down to < 6MiB.


We've had 2.6 and 3.x series ARM32 images under 2Mb on our older products. 4.x is around 6Mb indeed, but these are also on hw with more peripherals.


Dang, I remember making kernels that fit in a 1.44mb floppy disk using the Linux Router Project, those were the days!

https://en.m.wikipedia.org/wiki/Linux_Router_Project


I'm not sure I'd ever want to build a setup with Busybox unless I was making a utility disk, but this was a fun read.

This brings back memories of when Linux was far more experimental. LILO was the new hotness in booting Linux (the much friendlier GRUB came later).

Also, (much) later, when Gentoo came along and you had to basically bootstrap your whole system...


or just use openwrt.org - there is x86/x64 and uefi support and it should only need 4-5mbyte with squashfs root :)


Back in the early days of openwrt that's basically what it was, if you went #freenode and asked questions about why your toolchain wouldn't cross compile correctly sometimes Erik Andersen would show up and ask about your env, distro, setup, etc.


What is the difference with minimal linux live [1]?

[1] https://minimal.idzona.com/


This is somewhat like initramfs image on Arch Linux.


If you are interested in that kind of work, i recommend you to look into the work of Rob Landley.


Noobs. In 2014 I built a full blown XFCE desktop distro from tarballs and used it for 3 years.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: