Future Tech

OneFileLinux: A tiny recovery distro that fits snugly in your EFI system partition

Tan KW
Publish date: Tue, 10 Sep 2024, 06:18 AM
Tan KW
0 475,478
Future Tech

OneFileLinux is a very different sort of distro that runs entirely from your UEFI system partition, without a bootable USB key or any other partitions on the disk.

The OneFileLinux project has been inactive for a few years now, but it does work - and we feel that the concept is inspired. It points to the sort of thing that Linux distro vendors should be doing, rather than trying to work with proprietary vendors to further lock down the Linux boot process.

OneFileLinux squeezes a cut-down version of Alpine Linux into a single, 20 MB compressed file, which you copy into your EFI system partition (ESP). That's the relatively easy bit, although Windows goes out of its way to hide this partition from users so there are some extra steps needed to see it. Users of Intel Macs can just pick it from a list by holding down the Option key while turning their Mac on.

Unfortunately, UEFI implementations on generic PC compatibles are the Wild West by comparison. On The Reg FOSS desk's testbed Dell Latitude, we went into firmware setup, picked the option to add an entry, browsed for the file… and it didn't show up. The project offers some Linux commands to manually set it as a boot option, which worked fine, but made it the default with no option for anything else.

We reckon the core idea is superb, though. All PCs with UEFI need an ESP and it's often a few hundred meg in size. Even older Windows boxes have 100 MB or so, and it's usually less than half full. Squeezing a distro into a few tens of megabytes is not an impossible thing to ask. Decades ago, multiple distros managed to fit themselves on one 1.4 MB floppy. That's no help if you don't have a floppy drive, though.

As this vulture has discovered to his chagrin - and more than once at that - if some mistake or accident damages your ESP, Windows is unable to recover or even start. Its alleged recovery system needs a substantial partition of its own as well as a working ESP. Trying to resize the thing is very dicey too.

Any UEFI-capable OS needs a mandatory .efi boot file in the ESP, so why not make that file a bit bigger and embed a whole rescue OS into it? No other partition needed, and no rescue media. Not instead of the main OS, but alongside it, for emergencies.

So far around the hacker-friendliness spectrum that it ends up adjacent is the Unified Kernel Image plan of systemd creator Lennart Poettering. It too fits the core parts needed to boot a Linux distro into a single file in the ESP, but with the rest of the distro in a conventional partition. The idea is to compile a single, compressed file, containing boot loader shim, kernel, and initial RAMdisk image (or initrd for short), and then cryptographically sign it, helping administrators enforce Secure Boot. (As long as Microsoft doesn't accidentally break it again, of course.)

The Reg FOSS desk, being a venerable codger in Linux terms, remembers the times before many distros had an initrd. He vividly recalls compiling his own kernels to precisely match his hardware, eliminating the need for any supplementary files. This was standard practice in the 1990s.

Today this kind of thing is only common in the embedded space - but that does mean that tools exist, such as from the Yocto project, to automate building custom kernels. Here's an idea: keep the original kernel from the install media around as a backup. It's handy because it can boot on any hardware thanks to lots of drivers in loadable modules. Then, for normal operation, automatically detect all the drivers in use on a given machine and compile a kernel with just those built in. Then we can dispense with the initrd altogether.

Coupled with an embedded rescue system along the lines of OneFileLinux, this could offer faster boot times together with more recovery options - while at the same time retaining the ability to boot even on totally different hardware. ®

 

https://www.theregister.com//2024/09/09/onefilelinux_esp_distro/

Discussions
Be the first to like this. Showing 0 of 0 comments

Post a Comment