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].
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.
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...
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.
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.
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).
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.
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.
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...