11 ms·
I Built Linux from Scratch
- mydriasis 3y agoI highly recommend building an LFS. It was one of my first big personal endeavors with computers. In the article, the author says they didn't learn stuff that'll _necessarily help them in their day-to-day_, which I can echo, but I definitely learned a lot about different commands, the file structure of linux, `hier`, changing root, cross-compiling, toolchain building... it's really an awesome and fun process, and is especially satisfying when you manage to boot into it for the first time. I will say I'm much less fearful of the GRUB CLI than I used to be ;)
- imthesloth 3y agoYeah i totally agree with your comment. Just to clarify for anyone reading this - it was not my intention to downgrade the value of building an LFS, but rather i wanted to set a realistic expectations on what you can expect to learn, so that you don't do it for the wrong reasons.
- spudlyo 3y agoI wrote this a few years ago, when LFS made the front page: I had a lot of fun doing this. You really get a feel for the evolution of build systems -- from older software that uses automake/make to newer programs that use meson/ninja/cmake etc. It was also cool to learn how to bootstrap a bespoke set of development tools tuned for your hardware. It took me a solid weekend to get everything built. I was able to get a basic LFS system built on a Saturday, and on Sunday I did the "Beyond Linux From Scratch" edition. At one point I got stuck trying to debug a weird interaction between systemd and PAM that took me a while to unravel. That was humbling, I thought I knew just about everything about Linux, but turns out there are large areas where I just don't have a clue. The docs are well written and maintained, so there wasn't a lot of frustration there. Even if you're not an old hand at Linux you can likely get pretty far by just diligently following the instructions. I struggled a lot more trying to make a decent desktop environment than I did getting the OS setup. I spent so much time trying to get a nice-looking toolbar (polybar) and basic stuff (like how patched fonts work) took me an embarrasingly long time to sort out. I also didn't know what a compositor was, or why you might want one. I enjoyed figuring out the basics of compton, which allowed me to get cool transparent backgrounds on windows[0], although I never did quite figure out how to get rounded corners. [0]: https://muppetlabs.com/~mikeh/spudlyo.png https://muppetlabs.com/~mikeh/spudlyo.png
- WesolyKubeczek 3y agoI did LFS back when autoconf/automake was considered a modern way to build software.
- gary_0 3y agoFor something that's more of a prepackaged build-your-own-Linux kit, there's also KISS Linux[0]. It's kind of a microdistro with minimal abstraction over the raw guts, and "packages" are just pre-downloaded source code repos that you compile yourself. The "package manager" is just a shell script. The installation process[1] is entirely manual, so you control every step as you bootstrap up to building your own kernel and installing each subsystem, all the way up to compiling and running Firefox. It's pretty neat. [0] https://kisslinux.org/ https://kisslinux.org/ [1] https://kisslinux.org/install https://kisslinux.org/install
- abbbi 3y agounfortunately its been maintained by only one dev which seems to have turned its back onto tech and has fanished from the web entirely[0]. I think its been forked since and maintained by a small community[1]. I liked the concept and used it for some tiny test machines. [0] https://www.reddit.com/r/linux/comments/m4pwix/what_happened_to_k1ss_linux_and_dylan_araps/ https://www.reddit.com/r/linux/comments/m4pwix/what_happened... [1] https://github.com/kiss-community https://github.com/kiss-community
- cookiengineer 3y agoThere's also TinyCoreLinux which is amazing when being bundled with busybox, for both embedded and VM use cases. [1] Though these days I would probably recommend to go with Yocto [2] for the sake of stability and updates. [1] http://tinycorelinux.net/ http://tinycorelinux.net/ [2] https://www.yoctoproject.org/ https://www.yoctoproject.org/
- wheelerof4te 3y agoIf you need something more practical, but still challenging, try Slackware. Use the advanced install feature and only select the packages you need. Build the other software yourself. You can choose your own difficulty this way. You can also follow the distro's way of packaging up software (build scripts), or build it the software developer's way. The main advantages of building software yourself are: 1. You are a developer who wants to customize the software. 2. You want to practice. 3. You want to contribute to a project. 4. You want to have a better understanding of what the code does. Slackware 15 is a modern platform to build upon.
- boomskats 3y agoI haven't run Slackware for maybe 20 years, but I remember running 7.2 at uni and recall really _enjoying_ building everything and having that level of control. It taught me so much about how Linux works. Conversely, I remember finding my initial experiences with dpkg and rpm quite frustrating in comparison.
- ilyt 3y agodpkg had a bit weird experience, because the "easy" way of building (binary)package is literally "just put files that need to be deployed in one directory, and some metadata in the other and run a command to package it", i.e. extremely easy and entirely independent on how you build it. But the "proper" way includes million scripts and checks that make sure your .dpkg is "distribution grade" and it can be quite complex
- Shared404 3y agoIt seems to me that slackware + flatpak could make a _really_ stable base for a desktop, but I've not got deep experience with either so could be making stuff up.
- qorrect 3y agoCame here to mention Slackware, my first distro and introduction to linux back in the late nineties. I thought they had abandoned it , glad to see it's still around. IceWM gang anyone ?
- marginalia_nu 3y agoI built LFS like back in 2005 or something. I remember it took forever. I wonder if it's faster or slower now. My computer is definitely faster, but I also have a creeping suspicion the code has gotten a lot bigger. Then at some point I switched to gentoo. I remember I vacillated between gentoo and slackware. The important thing was that I had an onion on my belt, which was the style at the time.
- TillE 3y agoSame, I used LFS for a couple months in college until I got annoyed about manual updates and switched to Gentoo. And back in those days you had to do it on actual hardware, not a VM. I had a job interviewer at the time who asked which Linux distro I used, and it was fun to tell them about that. I would definitely recommend going through LFS to anyone maintaining Linux systems, it really helps you understand how things work.
- guerrilla 3y agoI did it in the early 2000s and last year. It's a bajillion times faster now.
- School-Cotton 3y agoIt's almost certainly faster if your computer is remotely modern. Compilation scales pretty well with multi-core performance.
- dessimus 3y agoSignificantly faster. A few months ago, after building a new rig for the first time in 6 years or so. I did a gentoo build from minimal to gnome, as exercise/burn-in/cooling testing. With the amount of RAM and cores available now compared to 2005, an 'emerge -e @world' only took a few hours vs the days and days it took back then.
- solomonb 3y agoI did this back in highschool (so 1ate 90s). It was a really fun experience but I don't think I learned as much as I had hoped. I learned a lot about bootstrapping a system but not how to maintain it. It turns out package managers are really important for that. I ended up using the system for a few months until it collected enough cruft that I started over with some other distro.
- helij 3y agoSome 20 years ago I went and built "Linux From Scratch". I think this (among other similar exercises I did) enables me to find my way pretty quickly around any new or old tech thrown my way. I highly recommend this to anyone interested in 'computers'.
- polski-g 3y agoIf you have children, a much better investment is to have them install LFS and forbid them from using Windows/Mac, compared to going to college. I did not learn a damn thing in college because I'd been using Linux since age 12.
- TuringTourist 3y agoIf you approach college or any education with the attitude that you know everything already, you will likely learn about as much as if that were actually true.
- jterrys 3y agoPerhaps you missed the point of college if all you did were things within your comfort zone
- freedomben 3y agoI would guess GP meant "about Linux." I had the same experience with college. I'd been using Linux for years and learned nothing new about Linux in college. It was nice because the class moved fast and a lot of people who had never Linuxed or CLIed in their lives really struggled to get through it and keep up.
- pessimizer 3y agoMaybe they missed your point, but plenty of people with expertise go to college in order to get a piece of paper that allows them to work. Making it a middle-class spiritual rite of passage isn't the only way to do college right.
- sweetjuly 3y agoThey could've taken other classes then? Lift the lid a bit, learn about computer architecture, VLSI, transistor physics, fabrication, analog devices, MEMS, antenna design. If you already know a lot about computer science, it's unsurprising that you wouldn't learn too many radically new things just computer science classes, but you don't have to do that. Stay curious and seek out things you don't know.
- Xeamek 3y agoAfter I finish the whole process, can I slap pacman on top my freshly build LTS and effectively transform it into Arch and daily drive it? Or is it only meant "for the journey" of building it, but can't realistically be used as a daily?
- mewse-hn 3y agoIt's not really intended to be a daily driver once you've built it. There is "beyond linux from scratch" that extends the system but.. normal distros with normal package managers are just infinitely more usable than a LFS system. It really is just about the journey and learning how it works from zero.
- cyberbanjo 3y agoWhy do that when there is pacstrap?
- Xeamek 3y agoBecause I want to experience LSF?
- ingenieroariel 3y agoI have used NIXOS_LUSTRATE (wipes the other Linux on the next reboot) on several systems where it was not supposed to be used. Once you build nix, you should be able to boostrap NixOS from there.
- vmoore 3y agoThere's the LFS Project[0] route and then there's building things on top of the latest Debian or Arch releases. All are good learning exercises. The only real hurdle is installing drivers for things like Printers, Wi-Fi adapters, graphics cards, etc. That can be a headache-and-a-half. [0] https://www.linuxfromscratch.org/lfs/ https://www.linuxfromscratch.org/lfs/
- ttyprintk 3y agoBeyond Linux From Scratch (BLFS) is helpful with the latter.
- Daegalus 3y agoI did LFS back when I was a pre-teen/teen. So late 90s, early 00s. And while I agree to an extent that it doesn't give you much day-to-day stuff, it really makes you more comfortable with operating systems and linux especially. Nowadays, I am a devops/infrastructure engineer, and I can say LFS is a core foundational experience that has let me be better at my job. I know deeper inner workings of a Linux distro and that strong foundation helps. Yes there is so much more to learn but having LFS in your back pocket of lifetime experiences is great. I also think its a 1 and done kind of thing. I don't see a huge benefit of doing it again. Maybe for fun, in a VM while waiting for other things to finish. It is also much faster nowadays. Back when I did it, I had a 1ghz, 256gb ram machine, it took me days. I could probably go through it in a day casually with modern computing, and especially since I have a threadripper machine, sending 64 threads at the make commands im sure will get my 1 BU to be a very small number. If you have a child that is interested in computers, tech, programming, etc. I highly encourage this activity. Could be a fun bonding activity too.
- organsnyder 3y agoI had the same experience around the same time (though I'm a bit older). LFS really helped me understand the relationship between the bootloader, kernel, init system, and all of the various daemons and tools that make up a complete system. From there I moved to Gentoo, and then eventually to Ubuntu and other batteries-included distros. But the knowledge I gained from LFS is still a foundational part of my skillset, even though my roles have been more dev-focused than ops/infra.
- jonhohle 3y agoUntil I moved to FreeBSD in the mid 2000s I ran Gentoo primarily. Even though it had a bit more hand holding than LFS, it still taught me a lot and getting to choose implementations allowed consideration of design choices (cron, mail, syslog, etc.). I’ve tried to return a few times but it’s a bit different now and I’m happy enough with FreeBSD that I don’t have much place for it. I do wish more embedded distros would have started with Gentoo (specifically ARM SBCs).
- fefe23 3y agoThis link contains no additional information over the headline. He says he installed LFS. No need to click on the link.
- kitsunesoba 3y agoFor those who've been through LFS, would you say that it's a good first step for someone who wants to roll their own bistro at some point down the road?
- freedomben 3y ago> For those who've been through LFS, would you say that it's a good first step for someone who wants to roll their own bistro at some point down the road? <insert joke about the similarities between making sandwiches (bistro) and building a linux (distro)> Yes definitely! If you want to roll a new distro, I would dare say LFS is an essential step. Now that said, if your new "distro" is just going to be Ubuntu with a couple tweaked settings, you won't get nearly as much from it. But any non-trivial distro rolling you can absolutely benefit.
- kitsunesoba 3y agoHaha, autocorrect strikes again! Thanks, and yeah if I were to roll a new distro it’d be substantially different from anything currently out there.
- lrvick 3y agoRecently I was making an embedded linux image for enclaves where a shell and shell utilities did not make sense and high security and auditability was needed. I learned a bit of rust and wrote a minimal init system perfect for my use case: https://github.com/distrust-foundation/EnclaveOS/blob/master/src/init/init.rs https://github.com/distrust-foundation/EnclaveOS/blob/master... The init system is statically compiled into the kernel as a CPIO. This is about as bare bones as you can get with linux, and may help others understand the essentials. I was only able to do this because of years of running gentoo and building linux for various embedded projects. It pays off! You could swap out my init binary for busybox init and have built a full interactive linux distro from scratch in under an hour.
- INTPenis 3y agoI remember this being a phase I went through when I was in school. Back then I ran into the same issue as everyone else, it basically felt like Slackware, or FreeBSD with the ports but sans all the handy patches. I'd love it if their docs[1] actually mentioned how to install an existing package manager software on your LFS, that would basically make it a distro. 1. https://www.linuxfromscratch.org/lfs/view/stable/chapter08/pkgmgt.html https://www.linuxfromscratch.org/lfs/view/stable/chapter08/p...
- tguvot 3y agoI did it multiple times in past in a few companies where I worked on various Linux based network security appliances. Using standard Linux distros on them is problematic for various reasons. So I developed my own build system, which probably looked somewhat like Nix for building the distribution and managing updates. LFS was great place to start with
- threeio 3y agoI'm reminded of this in the very early days on my blazing fast 486... where you would go to build the kernel and walk away for two days waiting for the next compile failure.
- retrocryptid 3y agoI spent about two weeks in the early 90s with an unholy collection of DOS, 386BSD and Minix futzing together a bootable linux system on a 386/25 with 1M of memory. A couple months later someone told me about this thing called "SLS." I am definitely a fan of a decent distro. But yes... building Linux from scratch can be very educational. It's probably a right of passage for jedi geeks: LFS, designing and spinning your own SBC, using wireshark/ethereal to debug a borked Cisco router. Sadly, I still remember much more about LILO than I ever learned about Grub.
- 1970-01-01 3y agoDo the hashes match? Is it 'wrong' if they don't?
- imthesloth 3y agoHi, in which context are you referring to the 'hashes'? If you're asking about the hashes for required packages in 'Chapter 3. Packages and Patched', the hashes should match if you're downloading from the provided mirror - https://www.linuxfromscratch.org/lfs/mirrors.html#files https://www.linuxfromscratch.org/lfs/mirrors.html#files Downloading from these mirrors ensures that you have the exact version needed for the build, in any other cases you run the risk of the system not working as expected / documented in the book.
- 1970-01-01 3y agoNevermind, I thought this was about the Linux kernel.
- sprior 3y agoI did it in 2001 and it was one of the most educational things I've ever done. I think there should be a college course which gives you a box of computer parts at the beginning of the semester and at the end you get the grade displayed on a web page hosted on that computer built entirely from source. I have some precedent for that kind of thing, back in 1987 I made a deal with a prof that as an independent study course a friend and I were going to build a pair of voice synthesizers on IBM PC Prototype boards using the synth chips available at Radio Shack and he'd give us the grade my computer verbally asked him for at the end of the semester. I had no backup plan and it was a crazy risk, but we got A's and the teacher regretted not having us make one for him as well.
- charcircuit 3y agoIt's a waste of time. There is a reason why this is all done automatically. This is one of the things I think about when people say that "Linux is only free if you don't value your time." Even if you try and argue it is educational. Learning how to build programs does not require LFS. LFS is inefficient as a learning tool
- ilyt 3y agoI did it few times. It's so much easier nowadays with https://buildroot.org/ https://buildroot.org/
- kristianpaul 3y agoWait, no log or anything besides the sharing with the world that he did it?
- ktm5j 3y agoI got to do an independent study project junior year of highschool where I build the LFS project and went on to write my own (super basic) source based package management system. Was hands down the most valuable learning experience I've ever had. I highly recommend going through the process once if you want a better understanding about Linux/operating systems/compilers/toolchains!
- atum47 3y agoI started doing it back in 2019 after college, but at the same time I was doing job interviews with code challenges that would take 2 - 3 days, so I end up giving up halfway through. It was a miss calculation on my part, I underestimate how long it would take me to complete the whole LFS thing. Still on my todo list though
- denton-scratch 3y agoI deployed ipcop[0] routers a few times. Ipcop was a pretty good router. It could be booted off a 1.44MB floppy disk. It was built using LFS, so it took a while to install on a home-grade machine (like, a day!). This was ages ago; apparently they're still going. I didn't learn anything from installing it, except that it's possible, as a user, to build the whole toolchain, the OS, and the application, starting from assembly language. And that using LFS, you can make a really tiny Linux. Making a router was a good application of LFS; I'm surprised the search engines have forgotten it. [0] http://www.ipcop.org/ http://www.ipcop.org/ It's important that we can always do that.
- NikkiA 3y agoI developed professionally on top of a LFS system in the early/mid 2000s. In retrospect it was insanity layered upon insanity.
- BeetleB 3y agoFlamebait, but: > Slackware and LFS are the Haskells of the Linux distribution world. People jump to the extreme end of the spectrum, and either get burnt or remain unproductive for life, when they should have just used OCaml or F# instead. https://blog.nawaz.org/posts/2023/May/20-years-of-gentoo/ https://blog.nawaz.org/posts/2023/May/20-years-of-gentoo/ I've done both LFS and Gentoo. While LFS is certainly fun, in practice I don't think you really learn that much more than with Gentoo. The benefit of the latter is it's easy to stick to for life.
- nektro 3y agoI almost did it but it really didn't like that I was using NixOS as my host so I built a package manager instead https://git.sr.ht/~nektro/wifilylinux https://git.sr.ht/~nektro/wifilylinux
- nineteen999 3y agoI did one based around LFS a year or two back, but I used the Heirloom pkgtools stuff to publish packages in SVR4 format just for a laugh. I even packaged up and built CDE for it, it was a real fun parody of Solaris and other SVR4 systems. I called it HeadRat Linux. It really did add a nice spicy SVR4 style coating over Linux which I thought was kind of hilarious.
- afranchuk 3y agoI built an LFS system during one weekend my first semester of freshman year of college. I had too much free time I guess... At the time I made it a 32-bit system since LFS didn't (doesn't?) support multilib and I knew I would need some 32-bit libraries. I used that as my main system for quite a long time, upgrading software or installing based on BLFS or my own intuition as necessary. It worked pretty well! It was an invaluable experience in the development of my Linux expertise. After about 5 years I got frustrated with the 32-bit system so I did an in-place upgrade to 64-bit. It was thrilling to come out the other end of that, to say the least (seriously). The training wheels were definitely off, but LFS had educated me enough to be confident in doing it. Also I kept around all the 32-bit stuff of course, so I could incrementally upgrade things. After a few more years (maybe 2018ish?) I grew weary and changed to Arch (now I use void) :) All that being said, I highly recommend LFS!
- geocrasher 3y agoI built LFS in the early 2000s and I must say that I felt pretty much the same way. Compile times were pretty high for some of the items and it was fun to bootstrap the entire system. I learned a lot but I don't intend to do it again. I don't really need the knowledge these days.
- phendrenad2 3y agoI like LFS, and I think it's a good teaching tool, but probably most people on HN won't get much out of it. It's like building a car from a kit: You don't know why you're connecting the belt between generic oddly-shaped box A and generic oddly-shaped box B. I've thought about making an LFS where you use a bare kernel image and write a simple init process, with busybox as a backup.
- nubinetwork 3y agoI tried this twice, first time failed in stage 1... second time I got it all built but didn't build the kernel or boot loader... Its certainly a learning experience, but I'm happy with Gentoo thanks.
- jsdeveloper 3y agoI did LFS long back and replaced its default terminal as nodejs terminal.
- jsdeveloper 3y agoI did LFS long back and replaced its default terminal as nodejs terminal. It was fun and learned so much from it.
- yonatan8070 3y ago> replaced its default terminal as nodejs terminal What do you mean? Did you replace the login shell with a NodeJS interpreter or did you use a terminal emulator that ran on NodeJS?
- jsdeveloper 3y agoThe first process after kernel boots up was nodejs terminal. So when my machines boots up , i would see nodejs terminal, intead of bash.
- jordiburgos 3y agoIs the LFS faster than a regular distro? If the compiler takes into account your specific CPU and applies the available optimizations, it should be, right?
- jake_morrison 3y agoLinux from Scratch is educational but fundamentally impractical to use. I recommend using embedded Linux instead, e.g. with Buildroot. You get an understanding of the fundamentals of the hardware, kernel, and build toolchain. And you can create small hardware systems that do fun things. I ran Gentoo for a few years, and enjoyed it. Doing the install from stage1 gives you a similar understanding of how the pieces fit together and enables you to fix low level system problems, e.g. with disk failures. The community is also smart, as it self-selects for people who have skills and good attitude. Unfortunately Gentoo is too slow to install and quirky to deploy on servers.
- kruzda 3y agoCould someone here please let the linuxfromscratch.org admins know that you can't access their site from Starlink?