[HN Gopher] Linux from Scratch ___________________________________________________________________ Linux from Scratch Author : letientai299 Score : 117 points Date : 2020-08-21 19:22 UTC (3 hours ago) (HTM) web link (www.linuxfromscratch.org) (TXT) w3m dump (www.linuxfromscratch.org) | [deleted] | Daegalus wrote: | I think this is something every computer/tech/future programmer | should have done at least once, even if you give up half way. | | I did this when I was in early high school. I just got into | Linux, and this was super fun to do, it really showed me how an | operating system worked and all the moving pieces and how they | all fit. I did it all on a 1ghz machine with 256mb of ram, and | some slow DSL. It took me a 4-5 days back then, but it was a | blast for me. | | I haven't done it since. But today I am a senior devops engineer, | and that knowledge was so valuable to me today. It is so much | easier for me to reason about systems and linux in general. | | Honestly, I am really tempted to go through this again as a | weekend project in a VM or something | pram wrote: | Maybe. I did it and while it's certainly educational, most of | it feels like a waste of time. The bulk of the entire process | is running 'make' on random things and waiting. It's fine as a | teenager (when I did it lol) but as an adult with a job? There | are better/more productive ways to spend your time if you want | to learn more about Linux probably. | sprior wrote: | The first time I did this in 2001 it took me a week. It's still | up there as one of the most educational things I've ever done. A | perfect graduate level class would be "here's a box full of | computer parts, at the end of the semester I'll give you the | grade you display on a web page served by the computer you build | and compile from scratch". | saagarjha wrote: | I wonder if it would be less work to write an OS with the sole | purpose of pushing out packets for the hardcoded webpage... | kevinherron wrote: | So... basically pass/fail? Who's gonna get that far but type | 'F' instead of 'A' into the HTML they author? | sprior wrote: | Puts skin in the game. No kidding in 1987 I actually did | convince a professor to agree to an independent study course | for me and a friend to build a voice synthesizer on an IBM PC | proto board using the TI chipset available at the time and | the only terms of the class would be that he gave us the | grade my computer verbally asked him for at the end of the | semester. We actually built two of them, one for each of us. | It was wire-wrapped. We had no backup plan whatsoever and it | was a brave/stupid thing to do, but we both got A's and the | prof told us his only regret was that he didn't have us make | one for him too. Even more skin was that it went into my own | IBM PC, so if I blew that up not only wouldn't I have had | enough credits to graduate but PCs were very expensive at the | time. These days you can blow up a Raspberry Pi and who | cares. | vasilakisfil wrote: | Is this something that will allow you to create a new distro? | Foxboron wrote: | Sure, Arch Linux was bootstrapped with LFS by Judd around | 2001/2002. Back then pacman was written bash I think? | kenniskrag wrote: | yes, because a distro is a collection of software on top of the | kernel. | smcphile wrote: | It can be a first step to creating a new distribution, but most | people just do it as a learning experience. | | Here's one example though of someone who went on to create a | new distribution: http://www.nutyx.org/en/ | | To create a distribution, you need a package manager of some | sort to manage software updates, and while LFS discusses some | possible package managers that's not really its focus. | nix23 wrote: | No you build your own gnu/linux...from scratch. | cbsks wrote: | Be careful with this! It's a slippery slope from LFS to Gentoo. I | made the mistake of trying LFS once in college, and then I spent | the next 10 years compiling everything from source! Beware!! | timw4mail wrote: | Funny, I use Gentoo, and thought LFS was too far... | amelius wrote: | Better use a purely functional build system, like in NixOS, | where you can download binaries and have the guarantee that | they are the same as when you had built them yourself. | hvdijk wrote: | It's much closer to that than any alternative I am aware of, | but that's one guarantee you don't have. It's important to | limit your substituters (binary caches) to trusted servers, | because Nix does not and cannot verify that the binary it | receives corresponds to the source, only that the remote | server claims it does. Even if the binary does correspond to | the source, the build process may have picked up small | details about the build system, meaning a local build would | produce a different binary. Even if the build process does | not pick up any such details, many packages do not have | deterministic builds, meaning they might produce different | binaries even if you build them multiple times in succession | on your own computer. | reichardt wrote: | Something I've been wondering: what's the difference between this | and buildroot? | diegocg wrote: | buildroot is used to cross-compile Linux systems. It's a tool. | Linux from scratch is a guide that users are supposed to follow | to learn more about Linux. It's mostly an educational tool. | yjftsjthsd-h wrote: | That doesn't sound like a very big blocker; don't you "just" | need someone to "package" a compiler chain? | Thoreandan wrote: | "...the goal of LFS is to build a complete and usable | foundation-level system. This includes all packages needed to | replicate itself." | | http://linuxfromscratch.org/lfs/view/stable/prologue/package... | | Buildroot's target systems don't include a compiler - it's more | for real-world embedded linux system generation. | | https://buildroot.org/downloads/manual/manual.html#faq-no-co... | agumonkey wrote: | I never got into LFS, when I finished my build I was probably | exhausted by all the sed'in and patchin' and didn't have a single | clue about where the piece fit. | | I did end up with a flawed system with funny bugs. I couldn't | access the network with the usual tools but elinks managed to | bypass something and get a TCP stack somewhere. But it failed to | render properly on tty. No surprise I had no clue what I did | wrong but it made me realize how much plumbing there was. | dang wrote: | Related from a month ago: | https://news.ycombinator.com/item?id=23787526 | | If curious see also | | 2019 https://news.ycombinator.com/item?id=20149111 | | 2016 https://news.ycombinator.com/item?id=11829373 | | 2012 https://news.ycombinator.com/item?id=4488162 | | 2012 https://news.ycombinator.com/item?id=3677350 | | 2011 https://news.ycombinator.com/item?id=3171448 | | 2010 https://news.ycombinator.com/item?id=1779665 | spudlyo wrote: | Thanks Dang! | | It's interesting that in 2016 the top comment was about how | out-of-date the documentation was, which made it very | challenging for the novice to approach. When I did it in 2019, | my experience was very different -- I marveled at the quality | of the instructions and documentation, as well as how up-to- | date it was. | | In fact, just this week I was googling for some information | about building GPG without having to deal with generating PDF | documents, and I stumbled upon an LFS GPG page[0] that had been | updated that day. There seems to be a fairly active community | who is maintaining the guides. | | [0]: | http://www.linuxfromscratch.org/blfs/view/svn/postlfs/gnupg.... | [deleted] | sieste wrote: | I tried to go through this a few years ago. The time commitment | is huge, especially if you really want to understand all steps in | detail. In the end I lost interest because it turned into a | mindless command-copying exercise for me. My only real take away | was a much greater appreciation of the complexity of an operating | system. | | Has anyone followed this from start to finish and can now | comfortably compile their own linux kernel from scratch? | swiley wrote: | Wait, compiling the kernel and coreutils is the easy part. It's | when you get to X11/gtk/Firefox that it starts to get bad. | maxrmk wrote: | I followed through the whole process as an assignment for my | operating systems class in college. Overall I had the same | experience as you -- it was an exercise in copy and paste. | netsharc wrote: | I was wondering if it's automatable, and the site already | does that... | | I also did the whole book (manually!) as a slacker student. I | guess if you do it/let it run automatically as you read the | book, you'll know your installed OS inside and out... | hoistbypetard wrote: | Automating LFS is where Gentoo came from. | djxfade wrote: | What came first, ~~the chicken~~ Gentoo or ~~the egg~~ | LFS? | troutwine wrote: | I did as a teenager, probably close to 16 years ago. The | process was glacial because I lived in a rural area with | rudimentary internet access. Figure from start to finish it | took me a year? Gave me a lot of time to consider the different | pieces of software being compiled, which I probably would not | have done with a fast internet connection. Really helped jump | start my interest in systems programming and is surely one of | the experiences that pushed me toward the career I have now. | | I still feel pretty comfortable in compiling a linux from | source. Userland specialization is also a neat topic. | cel1ne wrote: | I did this 15 years ago, before I gave gentoo a spin. I | compiled my kernel for many years (make menuconfig). | | Bottom line: It's not worth it. | | I use debian now. | Bnshsysjab wrote: | I moved to Ubuntu for political reasons outside the fault of | gentoo. I really miss the ability to easily patch core libs | with custom patches, and portage (when it worked) was a lot | easier to deal with than apt. | fuzzer37 wrote: | Care to elaborate on the "political reasons"? I've never | heard of someone moving _to_ Ubuntu for political reasons. | Bnshsysjab wrote: | If I get breached as a result of using gentoo, it looks | bad. If I get breached using Ubuntu it's at least along | the lines of 'well everyone else is using it anyway'. | Semi safety in numbers, semi 'nobody got fired for buying | an IBM'. | | It wasn't my call, and it's a defense move rather than an | opinion on the state of Gentoos security. I know they | take things very seriously, but my assertions aren't | enough to make my employer feel comfortable. | barrkel wrote: | The point of doing it is to understand how Linux hangs | together, to remove the mystery in the wiring. | | I don't think it's worth pursuing to a GUI, unless you have a | burning desire to customize or fix brokenness in that | experience you've had on other Linuxes. | | The point is definitely not to continuously manage your own | distro you built from scratch, unless that's your job or hobby. | | I use the knowledge I gained from the experience to debug many | random instances of brokenness on Linux, both personally and | professionally. It also made compiling from source a fairly | comfy option when necessary (e.g. you need to fork, or backport | a piece of software). | blablabla123 wrote: | Yes I also did this years ago. During that time I was actually | also fascinated by the idea of building my own OS - which I | never did though. But if you do this, you really understand how | "GNU Linux" works end-to-end and stumble over a lot of | interesting things with the upside of having a system tailored | to your setup. | | I started using Linux when it was still necessary to compile | your own Kernel to support literally anything going beyond the | absolute base setup. | | The most difficult parts were bootstrapping the system and | getting the glibc stuff right. The rest is indeed rather | robotic, although I think there is some kind of package manager | now included. | jamiedamien wrote: | I followed this during winter break my first year of college | and loved it! Helped me learned Linux and co. pretty quickly | and I used the machine as my main computer for the next 3.5 | years of college. | | Once you get X and google chrome it becomes pretty self | sustainable. Updating the kernel is easy but upgrading the | compiler / C library is a nightmare. | | A lot of programs you might want to use provide binaries that | makes things a bit easier, but there were some annoying days of | dependency chasing if you have to install from source. I ended | up writing some custom scripts to ./configure, make, and make | install into a deb from .tar.gz. | | About the initial LFS process, I had messed up a few steps | pretty bad, and had to restart / go back one or two times. The | worst mistake was embarking on the journey first by installing | everything into a USB flash drive. Eventually data corruption / | loss ruined the yacc binary (or similar? hard to remember) and | I spent days trying to figure out what went wrong. After moving | to an SSD it worked better :) | | Definitely one of my favorite and most rewarding projects I've | done. | Skunkleton wrote: | I haven't done LFS, but I have built minimal Linux systems from | scratch as part of my day job. FWIW, building a _basic_ usable | system is fairly trivial, and requires no where near the amount | of work described in LFS. | | I could see value in building a basic Linux from scratch. | Beyond that you are just copy pasting commands from READMEs for | hundreds of projects. | spudlyo wrote: | 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 | anbux wrote: | How do i get started too? Where should i begin with? | input_sh wrote: | I don't know if you're referring to the Linux From Scratch | part or the desktop customization part of the comment you're | replying to, but if latter: | | Visit here for inspiration: | https://www.reddit.com/r/unixporn/ (safe for work, despite | the name). | | Pick a window manager, learn how to use it, and go from | there. Popular options are i3 (i3-gaps if you want some space | between windows), sway (i3, but for Wayland), bspwm, awesome | wm. Usually they're used in combination with polybar (highly | customizable status bar) and rofi as an application launcher. | spudlyo wrote: | That's right, /r/unixporn influenced me quite a lot. I read | a lot of folks' dotfiles that were posted there and was | inspired by the screenshots. Because I had built a lot of | software with LFS, I wasn't at all afraid of tackling | building custom versions of i3 (i3-gaps) and compton | (compton-tyrone) to get visual bling. | johnnythunder wrote: | Nice! I know the project maintainer and he is really methodical | about everything he does. Nice work Gerard. | johnisgood wrote: | On | http://www.linuxfromscratch.org/lfs/view/stable/chapter06/pk...: | | > Symlink Style Package Management | | For this I highly recommend https://zolk3ri.name/cgit/zpkg/ which | I have been using for years now. It works wonderfully. | | Environment variables and their defaults: | ZPKG_SRC = ~/.local/pkg ZPKG_DST = ~/.local | ZPKG_DB = ~/.db | | It means that if you install anything from scratch, you have to | `make install` (or the like, depending on the build system) it | to, say, `~/.local/pkg/foo-1.0` and then run `zpkg link foo:1.0` | to install (i.e. link) the "package". After that you just have to | make sure you have added `~/.local/bin` to your `PATH` | environment variable, and `~/.local/man` to your `MANPATH` | environment variable (in your `~/.bash_profile` file). Seems to | do the job. It does lack a README file for which I may contact | the author. In any case, `zpkg --help` should be of tremendous | help. | | By the way, I have noticed that someone created a package manager | with the same name, but its initial commit was in 2019, while | this one's was in 2017. ___________________________________________________________________ (page generated 2020-08-21 23:00 UTC)