This past week, on the recommendation of a friend, I embarked on the journey of building Linux From Scratch. LFS (as I’ll affectionately refer to it) is a book that walks a user through the process of compiling an entire base Linux system by hand. I’d like to share my experience with my first time going through this with LFS 7.6.
This is an excellent question, especially since there are distributions that offer nearly all the same benefits of LFS but in much more convenient packages.
The back story is that recently I’ve been a bit more curious what’s going on under the hood of my computer. One afternoon I went through the process of installing and configuring Arch Linux via it’s beginners guide, a process I found educational. Later that evening when hanging out with my friend Erik Jensen, I related my experience installing Arch and asked his advice getting started with Gentoo. After Arch, I figured Gentoo would be the next step in learning about Linux.
Instead of pointing me toward a specific guide or wiki, Erik immediately recommended that I instead go through Linux From Scratch. To paraphrase his explanation:
You should really do Linux From Scratch before you get started with Gentoo. Gentoo is complicated and can be frustrating. But if you do Linux From Scratch, you’ll learn a lot more about how Linux works and gain a greater appreciation for the automation and convenience that Gentoo does provide.
Wise words Erik! After going through LFS, I’m so glad it was recommended to me; so many questions about OSS, the Linux kernel, and operating systems in general, have been answered by this process.
Now, Beyond Linux From Scratch here I come!
These are notes on the Linux From Scratch process, intended to help out those who may also want to go through the process.
Take it one step at a time
If you where to print out the entire LFS book, it would be 354 pages long (from the PDF version). It’s a daunting process, and it can seem unendingly long. Fear not! LFS is broken down into small, easy to tackle tasks with explanations that will ease you through every step of the way. This isn’t to say it won’t take a long time; it took me approximately 5 days to get to a point where I could boot into my LFS system, and that’s spending several hours per day tiptoeing through the process. But if you follow each step, you’ll move through it faster than you thought!
Though that brings me to my next point:
Read the whole thing!
The LFS book is one of the best learning resources you’ll ever use; read every part of it! Every question you may have about a step or process will be answered, as well as many questions you didn’t know you had. But thoroughly reading each step will ensure nothing goes wrong and you’ll learn as much as possible.
The way LFS works, you will initially need a “host” system with the necessary tools to begin building Linux From Scratch. There is a list of host system requirements (this link is specific to LFS 7.6), but that doesn’t do you much good if you don’t know any distros that immediately fulfill those requirements.
On my first attempt, I installed Arch on a flash drive, then booted off that flash drive on the laptop I was using to install LFS. Everything went fine till I had to compile GCC, which kept erroring out. It turns out that Arch uses the absolute latest version of the GCC compiler when you install GCC. That meant I had the GCC-4.9.1 pre-release version, a version which LFS explicitly warns you against using. My Arch install fulfilled every other requirement for a host system, but this one I could not work around.
My final solution was to ditch Arch and install Ubuntu Server on my thumb drive, then install all the required tools onto that.
This ended up working out really well, since I could SSH into my host system (Ubuntu Server installed on a thumb drive running on the laptop I was trying to install LFS on) and issue commands from my desktop. By SSHing in, I was able to proceed much faster since I could copy and paste complicated configuration parameters straight from the guide into the command line, as well as use other SSH sessions to do things like double check a prior step while the current step was compiling. I’d recommend this process of SSHing into the host to anyone looking to do LFS.