Helping ordinary people create extraordinary websites!
GET OUR NEWSLETTER
Your Email:
 

How to Build Your Own Linux Distribution

By Frank Pohlmann
2005-07-06


Linux From Scratch

The LFS project is, obviously, based on the source files that are sufficient -- but not necessary -- to make up a basic Linux system. It has moved beyond the Linux kernel and the device drivers, because to produce a working Linux system, you have to add a complete compiler tool chain, a number of Linux assembler utilities, the glibc system library, system configuration tools, and tools connected to userland shell access. LFS is predicated on the assumption that a Linux or UNIX power user with some knowledge of scripting wants to get to know the workings of a complete usable system without having to delve into the kernel code itself.

To get acquainted with the way a Linux system works, the creators of LFS decided that compiling the system by following the tree of module dependencies would be a natural way to get to know the mechanics of an operating system in general and Linux in particular. After users have mastered the compilation process, they can start eliminating those parts of the dependency tree connected to system components that are irrelevant to supporting the operating system's primary purpose. It is feasible, for instance, to eliminate the compiler tool chain itself after compilation is complete. Embedded LAMP stacks can make do without a full set of command-line utilities. Configuration utilities might be dropped, as well, and most users can make do with one, instead of the plethora of file systems Linux tends to support.

Linux parts
One important part of the LFS system is the large number of source files available as tar balls. Documentation is another vital part -- and the most important. Indeed, it would be perfectly possible to take an up-to-date LFS book file and create an LFS distribution, because each download location and the characteristics of each source file and its dependencies are described in the LFS book in detail. The procedures for compiling each group of source files from the kernel to the compiler to the shell have been written up, and you can find alternative routes -- where they are possible -- in LFS books describing systems with different characteristics. Another part of the LFS system that is unlikely to be in the toolkit of the average power user is the boot script needed to boot the system after the basic LFS system has been pieced together.

Now for the big caveat of LFS distributions: What a courageous distribution builder needs is a working Linux distribution, including a complete compiler tool chain and a suite of file system-creation utilities. Naturally, all source-based Linux distributions need to be bootstrapped using a particular compiler version, which is by no means identical from distribution release to distribution release. LFS is not the only system in this field, but it is the only system that allows you to work directly with individual source files. Most other source-based Linux systems, such as Sourcemage and MyGeOS, provide a complete download, which users are well advised to use. LFS makes no such assumption, and stripping down the LFS framework is encouraged.

Presuppose a functioning Linux distribution installed on nonexotic hardware, even though LFS is probably less demanding as far as configuration tools and scripting are concerned. To compile LFS, you need to prepare a partition and a file system, and you also need to compile a compiler and system library. It is a fairly nerve-racking procedure if done by hand, but it definitely increases your confidence in dealing with the rest of the installation. The compilation of the whole system tends to take from an hour to four days, depending on the age of the underlying hardware and your command-line dexterity.

If -- and this is a fairly big assumption -- you're willing to retain much of the book installation and keep changes to the installation proposed in the LFS book to a minimum, you could also use the automated installation routine to install an LFS-based distribution. The installation routine is not presented in the LFS book, but is available as an XML-based description under the name Automated Linux from Scratch (ALFS). The active installation is available as a C-based script that uses ncurses to give some semblance of a graphical installation. The installation is also known as nALFS and presents an extremely flexible package installation framework. It needs a functioning Linux system with a working C compiler and XML parser to work. A working LFS system would suffice.

Automated Linux From Scratch
ALFS has a purpose that goes beyond LFS itself. LFS on its own teaches the inner workings of a Linux-based operating system, but it does not include a single graphical user interface (GUI). Neither does LFS permit connecting to a network or, indeed, the Internet. ALFS can simplify extending the system -- for example, by adding the libraries enabling Internet access or by installing the X libraries required for graphical desktops.



Tutorial Pages:
» Go to the source to learn Linux basics and build the right Linux for you
» Why UNIX internals matter
» Linux From Scratch
» Beyond LFS
» Hardened LFS
» The growing LFS family
» Resources


First published by IBM DeveloperWorks


 | Bookmark
Related Tutorials:
» How to Install PHP 5 on Linux
» How to Install Apache 2 on Linux
» How to Install MySQL 5.0 on Linux
» SMB Caching
» Mound --Bind
» Tar Wild Card Interpretation

Advertise with Us!


Tutorials Scripts Web Hosting Developer Manuals
Resources