🐧 Reflections on Building Linux From Scratch
For most of my life, I was a Windows user. I grew up playing StarCraft and WarCraft on the family Windows PC, then later built my first gaming rig running Windows Vista. Throughout most of my life, through undergrad and grad school, from Vista to 7, then 8 to 10, and so on, I was a firm Microsoft Windows user.
When I was building systems to run experiments in grad school, it really started to sink in how I was standing atop a massive, invisible tower of abstraction, one in which brilliant people had been constructing for decades before me. It felt like the scripts I was writing were miniscule compared to the entirety of the operating system itself, it was just a black box.
While my knowledge of computers grew, I couldn't help but feel that with each new "upgrade" to Windows that I installed, the OS itself became more obscure and less under my control. Every new version came with more features I didn't want, software I couldn't remove, or settings that were buried deeper and harder to get to. I wanted to understand what was happening under the hood, how the OS worked, and how I could control it.
I started experimenting with Linux inside WSL, setting up VMs, and eventually set up my first Linux server on a Raspberry Pi. I made the leap to running Linux full-time on my desktop, even if it meant it would be harder for gaming. Ironically, this turned out not to be case, that with Steam offering native Linux support and Wine enabling Windows-native games to run directly on Linux, it's barely even an issue. Still, even after switching, I felt like I didn't really understand how the mainstream distros I was using, like Debian and Ubuntu, really worked.
🛠️ Building Linux From Scratch
When I first heard about Linux From Scratch, I knew it was something that I wanted to do. I'm not going to lie, the first time I opened the LFS book, I was intimidated. Once I got started, it was actually quite straightforward and approachable. The overall recipe is quite linear, where each step builds on the last, and as you go, you begin to appreciate the tiny pieces that make an OS come together.
I'll admit though, it's hard to say if I fully absorbed all of the details. There were several configuration recipes that I didn't fully understand their purpose, and it's hard to keep track of all of the tools that were installed or needed for the system to run. I would like to be able to know exactly what each file, every tool and script is used for, so I can cast those magical coding spells on my system that comes with being a true Linux wizard. Still, every step felt manageable, even if I didn't fully understand every single detail, and left me feeling confident that I understood what was going into my new Linux build.
The process itself was smooth. I did encounter a few build errors and test failures here and there, but each time I was able to trace it to a typo or a simple missed step in one of the lines previous. The most challenging part of the process was configuration of the kernel and setting up the bootloader. Unlike compiling packages which gives you clear error messages, setting up grub and EFI is more work. The instructions are more abstract and meant to guide you in how to think about setting up the boot loader for your specific configuration (multiple OS's, shared boot partitions, UEFI versus legacy, etc). It's also difficult to know if the boot loader you've configured is actually setup correctly. There was a part of me holding my breath everytime I did a system reboot wondering if I had somehow accidentally nuked my base OS's boot loader, leaving me completely SOL. It's good to keep a recovery USB handy just in case!
The first successful boot into the new system was incredibly satisfying. Selecting the LFS boot entry on a unified grub menu alongside my Debian install, watching the LFS prompt appear after a successful boot sequence, a clean, minimal environment fully detached from the Debian host OS; the experience was exhilarating. I align with what Richard Feynman said, "What I cannot create, I do not understand". By building Linux from scratch, I understand better how OS's work, and feel aptly equipped to identify the purpose of and manage the moving parts involved in making the OS run.
🧠 Lessons Learned
Is it really worth it to build an OS from scratch in the modern era? It's certainly much easier to install one of the many Linux distros, like Arch or Ubuntu, and have a perfectly fine desktop up and running within an hour. But, if you're like me and want to actually understand how the technology you use on a daily basis works, AND have the ability to control what goes into your operating system, then I would argue that the experience of building Linux From Scratch is absolutely worth it.
I'm not sure yet if I'll make my LFS system my daily driver, but I would certainly like to keep the project going. I'd like to explore the Beyond LFS book and perhaps set up a window manager. On my main desktop PC I use for gaming, I'm curious to know how much I could push performance with configuring a custom kernel. It would also be cool to automate creating my own images so I can deploy them across systems. Whether or not I stick with it long term, I've learned a lot through this project and gained a much deeper understanding and appreciation of Linux.