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?

17 comments

  1. [4]
    redshift
    Link
    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...

    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.

    17 votes
    1. eledrave
      Link Parent
      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...

      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.

      7 votes
    2. [2]
      Akir
      Link Parent
      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...

      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.

      5 votes
      1. redshift
        Link Parent
        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...

        configure your kernel

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

        5 votes
  2. vord
    Link
    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....

    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

    8 votes
  3. Crestwave
    Link
    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...

    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.

    6 votes
  4. akkartik
    Link
    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...

    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.

    5 votes
  5. [4]
    Comment deleted by author
    Link
    1. [3]
      Akir
      Link Parent
      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...

      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.

      6 votes
      1. [2]
        arqalite
        Link Parent
        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...

        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.

        3 votes
        1. Akir
          Link Parent
          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...

          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.

          2 votes
  6. [3]
    lostwords
    Link
    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...

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

    2 votes
    1. [3]
      Comment deleted by author
      Link Parent
      1. [2]
        arqalite
        Link Parent
        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...

        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 and musl, 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.

        1 vote
        1. [2]
          Comment deleted by author
          Link Parent
          1. arqalite
            Link Parent
            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.

            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.

            1 vote
  7. zatamzzar
    Link
    I learned a ton of things about bash from following the tutorials and reading the scripts.

    I learned a ton of things about bash from following the tutorials and reading the scripts.

    2 votes
  8. whs
    Link
    I did LFS over 10 years ago. Here's a few things I learned LFS list what each packages you're compiling provides - I learned that many "Linux tools" is actually part of the coreutils software The...

    I did LFS over 10 years ago. Here's a few things I learned

    1. LFS list what each packages you're compiling provides - I learned that many "Linux tools" is actually part of the coreutils software
    2. The GCC section talk about cross compiling and stuff. I think a question that many people will ask is how is a compiler was first created. You'll realize the "from scratch" part is false when you use gcc in the LFS CD to build your gcc so that's how the chicken and egg problem is solved in this case.
      • Side note: I recently blogged about that question, and I referenced that LFS section that it actually answer the question of how compiler in a new platform was first created - by cross compiling, and how exactly does that process work.
    3. It demystified Linux "distribution" that a Linux system is not developed by Canonical (the Ubuntu company) or the Debian project, but in fact it was developed piece by piece by several projects, then the "distribution" is a compilation of required projects
    4. Although LFS didn't teach me this, but it was a stepping stone for me to understand the inner working of a Linux system. Even today Windows feel like a blackbox to me - I don't know how its booted, which software provide the GUI, who start the service manager service, where on the disk is the OS configuration (registry) is stored. While you could read about all those questions in Linux, LFS provide a hands-on approach and for my learning style I don't feel like I can apply those knowledge without a hands on experience.

    It's probably like that "Kubernetes the Hard Way" guide, but I haven't read that one yet.

    1 vote
  9. Pavouk106
    Link
    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...

    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.

  10. [2]
    Comment removed by site admin
    Link
    1. vord
      Link Parent
      OTOH, booting into a raw kernel is pretty boring. At least with LFS you've got a basic, but workable system.

      OTOH, booting into a raw kernel is pretty boring. At least with LFS you've got a basic, but workable system.

      1 vote