What a slacker learned from building Linux from Scratch...
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
What a slacker learned from building Linux from Scratch...
Once again I'm writing about another "distribution" purely from a Slackware user's perspective. But this is a little different. I put distribution in quotes because Linux from Scratch (LFS) is a distribution in the same way that corn meal, flour, sugar, baking powder, salt, and an egg is corn bread -- you have to make it yourself following a recipe. Everything is built from source.
The LFS web site provides the recipe and the ingredients (the maintainers make available both links to the software sources and a nice tarball with all of the sources and patches in one place). But more than that, it provides a lot of explanatory material to go with the build instructions. If one pays attention, one can learn a lot about how GNU/Linux works.
That last should sound familiar to slackers. The oft-repeated mantra, “If you learn Redhat (or Ubuntu or Debian), you learn Redhat, but if you learn Slackware, you learn Linux,” is a rallying cry for Slackware users. I’m not sure it’s precisely true -- not a lot of Linux distributions use the BSD-style initiation/boot scripts -- but it is pretty close to the truth. There aren’t a lot of patches to upstream sources and slackers have to do a bunch of configuration by editing text files. LFS is like Slackware in that regard, just more so.
Quick and Dirty Take Home Message
1) Is LFS worth the time and effort to build?
Absolutely!
2) Will I learn a lot about Slackware by building LFS?
Yes.
3) Is it hard to build?
No; especially not for Slackware users, many of whom are used to compiling software and configuring things by hand.
4) Does it take a long time?
How much time do you have? It took me two months worth of evenings and some time on weekends. I’d spend an hour or two on it after my kids went to bed on most evenings. I hit a few snags and had to backtrack a couple of times. I estimate 80 hours or so worth of work, but that includes the time to compile all of the packages, during which I could do other work. I’ve got a pretty fast computer, but not the fasted available. Your compile time could be much shorter or longer than mine. I also did more than strictly follow the LFS book; I used a package management scheme where I built and installed each package as a non-privileged user. That took more time, but not having package management, which is the default for LFS, was anathema to me. Finally, I added time to the build by documenting it as I went. One could probably build the whole thing in a weekend if one is simply following the book, running a pretty fast computer, and not doing much else.
5) Okay, but is the finished LFS system useful?
No, or yes, depending on what you do. The resulting system is really fast, tight, optimized for one’s own hardware, and really, really basic. If you want to actually do any work, you’ve got to build and install a lot more software, which is detailed in the “Beyond Linux from Scratch” (BLFS) project.
The Details
I built LFS version 6.6 (version 6.7 was release when I was halfway through my build) using 32-bit Slackware 13.1 running in a QEMU-KVM virtual machine. Slackware64_13.1 was the virtual machine’s host, and my regular computer, but that’s not relevant to the LFS build. Slackware 13.1 was the perfect host for LFS. Nothing needed to be added to it or recompiled to properly build the temporary LFS toolchain, which one then uses to build the LFS system. In other words, Slackware’s native development environment is fantastic for projects like this.
I did a few things differently than the instructions. As mentioned above, I used a package users scheme for package management. Additionally, the LFS book has one installing Vim, but I installed Emacs and Nano instead. Frankly, the joke about Emacs being a very good operating system with a mediocre text editor is uncomfortably close to the truth. With Emacs installed, the final LFS system is actually very useful for a lot of what I do with a computer. Finally, the LFS book calls for building and installing Grub2 and then overwriting one’s boot sector after configuring it to boot the new LFS and existing OSs on the system. I skipped that step and simply added LFS to LILO after I was done. I didn’t feel like learning all about a new boot loader at this point.
Why is LFS valuable to Slackware Users?
The bottom line, if you are like me, is that you can read about something and research it, but until you do it, you won’t really understand it. The key is understanding not just what goes into a Linux system, but how everything interacts.
After 80 hours of admittedly fun work (I’m a geek), I’ve got an extremely basic GNU/Linux system that runs Emacs as its flagship application. In contrast, I could spend about an hour installing and an hour configuring Slackware and have pretty much everything I need. But what I don’t get from simply installing slackware is a systems-level understanding of where each package came from. I now know where each basic program and utility comes from, how it is built, and to a certain extent, how the programs depend on one another.
For example, ‘less’ is probably in my top 10 command list, but it’s not installed until late in the process. Similarly, I installed the man pages very early in the process, but couldn’t actually read them until Man-DB rather late in the process. Now that I know how the basic Linux utilities interact, I’m more comfortable troubleshooting problems with Slackware. For ,while Slackware does not have dependency tracking, it most certainly has dependencies. Building a system teaches me about those a lot better than simply installing pre-compiled binary packages from the Slackware DVD.
More to the point, I gained a real appreciation for what it takes to actually build and maintain a GNU/Linux distribution. Gals and guys, we have it really easy when we use Slackware. Not only do Pat and his small team manage to build a complete distribution (with X and everything!), they also manage to incorporate bug-fixes, security updates, and new features and do it in such a way that it works on an exceptionally large variety of hardware and has great performance.
Frankly, looking ahead to BLFS and thinking about building X, much less KDE, Thunderbird, Firefox, and Open Office, I’m a little wary of the effort it is going to take -- especially when compared to simply installing Slackware. It is possible to build and maintain a full-featured LFS system, but it takes a ton of work.
So my recommendation is to build LFS, tinker with it, and learn from it. The LFS developers put a lot of effort into the project and it shows. There is, probably, no better way to learn about GNU/Linux. In the process, you’ll gain a real appreciation for what it takes to build and maintain Slackware.
Your experience is pretty similar to mine and i'd give the answers you gave to your questions.
Rather than go on to blfs, I thought I might try variations on lfs as it is a pretty tightly defined path and a little bit of me was disappointed that I didn't run in to any tough problems to solve, or in fact any unexpected issues. Going off piste isn't recommended by lfs, but I need to get lost a bit and then find my own way to really learn.
More to the point, I gained a real appreciation for what it takes to actually build and maintain a GNU/Linux distribution. Gals and guys, we have it really easy when we use Slackware. Not only do Pat and his small team manage to build a complete distribution (with X and everything!), they also manage to incorporate bug-fixes, security updates, and new features and do it in such a way that it works on an exceptionally large variety of hardware and has great performance.
Thanks for the review, Lufbery. LFS is a distribution I have not attempted.
On the topic of other distros, over the weekend I finished setting-up one Arch box. I have four Slackware boxes. I've been running Slackware for a bit; I think Arch is another good distribution for Slackers to try out. My Slackware and FreeBSD skills enabled me to get Arch up and running with some effort. The Arch documentation is excellent. Most of Arch configuration is done by editing /etc/rc.conf.
Arch is worth trying in my opinion.
One interesting off-piste LFS adventure is to use LFS as a recipe for bootstrapping Slackware.
To do that, you can work through LFS Chapter 5, substituting the Slackware 13.1 version of each package for the LFS version. There are a couple of small tweaks needed
At the beginning of Chapter 6 you can install pkgtools into the chrooted environment, and then work through the rest of Chapter 6, building each package using the official SlackBuild instead of the LFS commands, and installing it with installpkg. Again there are a few adjustments required, but the methodology works very well.
I started doing this last week (it's relevant to a number of recent threads here at LQ) and I'll write it up properly as a blog post when I've got the last few problems ironed out. Yes, sysvinit, I'm looking at you
One interesting off-piste LFS adventure is to use LFS as a recipe for bootstrapping Slackware.
Good idea. I might give that a go if I can find the time. That'd give a great insight to the foundations of slackware. I imagine that you need to listen to the Grateful Dead to really get in the mood
The other idea I was toying with is going with busybox rather the usual gnu tools.
Good idea. I might give that a go if I can find the time. That'd give a great insight to the foundations of slackware. I imagine that you need to listen to the Grateful Dead to really get in the mood
The other idea I was toying with is going with busybox rather the usual gnu tools.
I used information from the Cross Linux From Scratch book when I had to bootstrap Slackware64 on the 32-bit Slackware. It gives great insight.
I can't see LFS displacing Slackware on my computers at home as the main operating system that I run for all the stuff I do with a computer.
But there's something about LFS that's very attractive. For one thing, the LFS developers do a fantastic job of putting everything together and explaining it well. I particularly like the process of building a system up from the bottom and adding what I want/need rather than trying to figure out from a whole, complete system how everything relates.
Secondly, I really like the package users package management scheme. It is surprisingly simple but effective, and I like that it only uses utilities built into Linux.
So, my next step is to repartition my IBM Thinkpad's hard drive and build LFS for it instead of in a virtual machine. The Thinkpad is my 2nd computer. It also runs Slackware, but I really only use it when my wife is on the desktop computer. Half the time I use the laptop to simply SSH into the faster computer and work on it at the same time my wife does.
So it's a good test bed for making a more fully functioning LFS system. It's an older Pentium III, so compiling software may take a while, but I think I'll get very good performance out of LFS, and eventually BLFS, on it when I'm done.
Have done 3 LFS installations in the past year, and I must say, it's pretty good. Have used pkgtools for package management, and the linux-libre kernel (with the pf-patchset), instead of mainline. All packages built with modified slackbuilds, with ability to upgrade packages, even glibc and the kernel, without any discomfort. So, all in all, pretty satisfying
I don't want to pre-empt Eric's reply, but what I'm doing at the moment is a weak subset of what he did to bootstrap Slackware64.
The problems, so far, are
(1) Older upstream packages that won't build with recent toolchain, libraries or whatever - patch (13.1 shipped a really old version), gpm, sysvinit, sysklogd, netkit-{ftp,rsh}. These can be dealt with by patching and/or upversioning. Google is your friend.
(2) Dependencies that LFS doesn't know or care about. Slackware is a coherent unified whole, and to reconstruct it accurately a lot of optional dependencies have to be baked in by building packages in the right order. The ldd command is your friend. Some of these are circular dependencies that require two passes. A few SlackBuilds sneakily use stuff you haven't built yet (wget inside usbutils and pciutils). Worst of all, there's gcc-gnat...
Additionally, LFS isn't perfect. There are a few signs of recent neglect (lack of volunteers?) and as the authors point out it hasn't been optimised for practicality. The order of building packages in Chapter 6 is perverse and leads to some of the fragility people experience when they "go off-piste". But that's apparently an intentional part of the LFS learning experience.
The best part of this exercise is reading Pat's comments in his SlackBuilds, some of which are quite droll
Thanks Lufbery for the review and everyone else for the input. I've always looked at LFS as something daunting, that I wanted to have a good amount of time set aside to put towards it. I may have to take another look at it.
One of the reasons I switched to Slack was to prepare myself for LFS. I'd tried once before about a month into my linux (mandriva) career and failed horribly. A month or so with Slackware made LFS fly by! I think it was 6.3 that I built using 13.0. My experiences were much like yours except that I worked virtually straight through and got the whole thing built in about a day and a half. I admittedly didn't absorb as much of the book going that fast as a I could have, but I was determined to get it built and just couldn't wait! I actually used a kernel config from 12.? to build a 2.6.27 kernel, so even my LFS was Slack at the core.
I too came away with an ENORMOUS appreciation for the work that Pat and crew do after building just a basic system. The amount of effort required to build and MAINTAIN a top notch, full featured distro is really quite impressive.
Hopefully this thread will lead to more Slackware forum member involvement & experiences with Slackware LFS.
You could also look at Beyond Linux from Scratch (BLFS) project which continues where the Linux From Scratch book finishes. The BLFS book introduces and guides the reader through additions to the system including networking, graphical interfaces, sound support, along with printer and scanner support.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.