19
votes
Does Linux From Scratch actually teach you anything?
Two hours ago I randomly thought "hey, why not do LFS?", so I opened my laptop and started following the book. I've heard a lot of people say that LFS is great for learning how a Linux system works. However, so far it's just been a guide on how to compile different software and what autoconfig flags to use. I thought that maybe further chapters will have more information on how things work, but it seems like they all just contain a one-line description of a program and compilation instructions.
If anyone here has done LFS, did you actually learn anything from it? Is it worth spending more time on?
In my experience, you'll inevitably have problems because the guide isn't perfect. Problems are where you'll learn.
If the guide is perfect these days, try changing compilation flags or replacing a subsystem with a competitor. You'll learn a lot about what those flags do and why certain combinations are important.
What redshift said!
I did it once and the learning happened between the lines, during compile time. What's that flag do? What does that package do? Oh, that failed; there's a newer/older version needed.
A lot of googling while compiling.
When I followed the guide more than a decade ago (probably closer to two, honestly), one of the things that bothered me was that it told you to apply patches but didn't tell you why. At least not in any significant detail.
Things have changed rather dramatically since then so I would be surprised if it asked you to manually patch anything anymore. Beyond that, the guide doesn't know what your hardware is so it's not going to be able to tell you exactly how to configure your kernel. It also teaches you how to use a lot of tools you might not otherwise have been exposed to, like chroot. Though to be fair, these are mostly things that you'd probably learn from something slightly easier like Gentoo.
Most Linux distros compile support for almost all hardware into modules that can be loaded at runtime. You can learn a lot by configuring a kernel without modules, and paring down the configuration until it just works. (I wouldn't recommend doing that for a practical kernel for most use cases, but it'll certainly teach you about the components of the kernel and why each is important.)
Beyond compiling software, I found it useful to start building the mental model of "this is required for that" and by the end it was kinda cool having an operating system that I assembled by hand.
The thing is, those brief one-liners add up. There is a lot of information to unpack. But here's a good example of an information-dense section
https://www.linuxfromscratch.org/lfs/view/development/chapter07/createfiles.html
LFS is great for learning about the system-level workings of a Linux distro. If you're interested in sysadmin stuff and build systems (packaging/porting/tinkering with software), then it could be a good fit for you. I know it was for me.
If you're interested in user-level stuff, then its teachings will likely just bounce off and prove not to be relevant.
If you're interested in programming-level stuff (how do I make an OS?), then LFS probably won't provide you much, either—just a very basic overview of the possible layers of a complete OS.
The problem is that "Linux" can mean so many different things to different people. As an example, I went looking at LFS when I wanted to understand how a "fairly real" operating system works. And I too was disappointed. But with hindsight (after having built an OS of my own), I think it wasn't LFS's fault. The information I was looking for was more technical, where LFS focuses on the more socially situated aspect of what the c compiler is called, what link you download it from, what other packages it depends on, and so on.
I just briefly skimmed through some of the introduction of the LFS guide and I'm realizing that the problem isn't so much that you don't learn anything so much as what you learn isn't terribly useful to most people. There are many smart people who could fairly easily be running on their own scratch-built linux systems but choose popular distros or even proprietary systems because they would rather not have their computer become a big project they need to work on.
As someone who does both, it's important to know when you can waste time on it, or when you just need to get stuff done.
I could get lost in Arch and/or Gentoo for weeks, but if I need to get something done, I'll pull up a Debian install and know it'll work perfectly and get the job done immediately.
I’ve been thinking a bit about this and I have come to a conclusion that it’s probably better for people who want to know how an operating system works is probably better off learning the tools that come with it - things like cron, systemd, tar, grep, see, vi, and the like. It’s a good thing to understand the more simple things like how hardware support works, but those are things that have increasingly been put into the “it just works” category for most situations.
I did get into the process of building it once. Honestly, it didn't feel that educational at that time. I have to warn you that it is a really tedious process, I gave up halfway. If you do extra research on what exactly each package does and why they are needed, you can learn a lot, you will also get a deeper insight on compilation flags, the capabilities of certain packages. You will get a bunch of errors along the way, some are easy to fix, others require a little more patience.
If you just want to purely educate yourself deeper on linux, I wouldn't recommend doing this, but if you also want to fidget with an OS in your freetime and you don't mind compiling a lot, then sure, go ahead. Or if you just have a thing for compiling, then install gentoo...
Honestly (and please don't laugh), Arch Linux.
It does give you a working system out of the box (if you don't want that, do LFS and read about what each package does online (or man pages)), but then you're left doing everything else. You want a GUI, install it yourself. You want sound, well pick your sound server. You want remote desktop? Try VNC, NoMachine or X11 over the network.
For me that's what most interests me about Linux. I don't care about the differences between
glibc
andmusl
, but I do care about why there are so many desktop environments, how to configure each one to my tastes, and what is actually needed to reach the level of polish and functionality a full distro like Ubuntu or Fedora has.Or why PulseAudio is hated by everyone and Pipewire is considered the next messiah. Or why Wayland is slowly replacing X.
Arch gives you all the choice in the world, and you can only make the most of it if you research and test each choice to see what it actually is.
If you like compiling software, try installing stuff exclusively from the Arch User Repository instead of using
pacman
. Or Gentoo, if you feel like it.For me it's a lot of fun. And when I'm stuck, the Arch Wiki is probably the most complete knowledge base about Linux software I've ever seen.
Ah, my initial assumption was that you weren't that familiar with Linux.
You probably know more than me at this point, so I don't have any resources to share.
I learned a ton of things about bash from following the tutorials and reading the scripts.
I did LFS over 10 years ago. Here's a few things I learned
It's probably like that "Kubernetes the Hard Way" guide, but I haven't read that one yet.
I think you can't understand how it works that fast. Also the question is what you want to understand. Linux is dofferent from Windows and different from Mac too (although probably not that much with Mac).
If you want to understand basics like folder hierarchy, softwae repositories and such, Ubuntu is enough. If you want to understand a bit more, like permissions, ownership of files etc., I'd sayprobably Arch is the way. If you want to go a bit more in depth (a bit) then Gentoo will give you some knowledge. And then when you want to understand comoilations and configurations of each package, LFS might be the way.
Arch is when you really start understanding the system, services, manual configuration (not compilation) of many things etc.
Gentoo goes deeper in that you can use USE flags, which sets what will and will nit be compiled in each package (like automake config) and gets dependencies resolved for you. You don't have hardware for H265 playback? Why would you need the codec then? You don't have printer? Then you don't need cups support etc. Also you have to compile yur kernel which ca be very cut down from standard distro kernels - you can include only your hardware (like NIC, FS support etc.). I use Gentoo exclusively for many years.
LFS is one step farther I guess (never used it), you probably configure each package by yourself and you have to resolve dependencies yourself, I presume.
Also - if you want to configure some service ornneed some helps with something specific regarding Linux, Arch wiki is the best.
OTOH, booting into a raw kernel is pretty boring. At least with LFS you've got a basic, but workable system.