Build Your Own Linux… From Scratch

Build your own Linux… from scratch. I can hear you thinking: “Build my own Linux… ok. But from scratch? Like a cake?!” Rest assured, no baked goods are produced (or harmed) in this course.

But it is possible to build a Linux distro a la “The Cake Boss” — using a bit from this can, that box, this jar. Assuming things fit together and work properly, the problem with this process are the limitations inherent in working with pre-packaged components. Don’t want wheat in your cake? If there’s no pre-packaged gluten-free cake mix, you’re out of luck. In much the same fashion, if you want userland binaries or the Kernel built (a) with (or without) certain features, (b) to fit into a pre-determined space, (c) optimized for a specific CPU…well, if you can’t find a box on the shelf, so to speak, you’re also out of luck, unless…

You’re willing to grind your own flour, which in this context is a metaphor for compiling code. There are any number of reasons you might NOT want to do this: it is time-consuming, requires meticulous attention to detail, is error-prone, and can be incredibly frustrating. On the other hand, there are an equal number of reasons you might want TO do this: you need to build for a certain CPU, or maybe trim down on some of the unnecessary software installed, remove debugging symbols… things like that.

Usually, if you’re going to build Linux from the source (“from scratch”, as it were), you’re doing so for one of three reasons:

You have specific needs in terms of hardware.

You have specific needs in terms of space.

You enjoy pain.

Jokes aside, building Linux from source can be rewarding and informative. If nothing else, rolling a custom distribution from source so can provide a great deal of insight into the “what” and “why” of Linux distros.

BYOL follows, closely, the “Linux From Scratch” (or “LFS”) build process. The result is an extremely basic Linux installation. And I do mean basic. It is a fantastic “leaping off point” for creating myriad purpose-specific Linuces. (Not, however, a great foundation for your new X desktop.)

The biggest drawback of building Linux from source is the lack of a package manager. Updates tend to be a bit demanding without one. Some distros (Arch and CRUX, for example) have incorporated building from source into their structure. In contrast, a custom-built distro has to be updated manually without the assistance of a package manager to handle dependency chains, library conflicts, and versioning. (You can, of course, install a package manager.)

Still, the BYOL course will give you a solid understanding of how the pieces of a distribution fit together, as well as how cross-compiling works. With IoT burgeoning over the horizon, this is a good set of skills to have.