In the midst of all the excitement surrounding the release of Fedora
Core 2 this week, some of the smaller projects that announced new
versions at about the same time might have escaped attention.
One of them was
Linux
From Scratch 5.1.
As the popularity of Linux increases, many people ask: "Is there a fast
and fun way to learn the ins and outs of the Linux operating system?
Are there any entertaining alternatives to conventional training
courses and books?" For many, the answer might very well be Linux From Scratch (LFS), a
book that provides step-by-step instructions to build a complete Linux
operating system from source code available for download on the
Internet.
Linux From Scratch is a mature project. Its beginnings date back to
December 1999 when version 1.0 was released. In it, the book's author
Gerard Beekmans explains
the purpose of the new "distribution":
I started this document about 6 months ago. I
tried a few Linux distributions and came to the conclusion that there
wasn't a distribution I totally liked. Every distribution has its own
advantages and disadvantages, but I was never satisfied with what I had
(although Debian comes very close to what I want), so I decided to
explore the possibility of building my own Linux distribution using
nothing but source code of programs. As I found out there's quite a bit
of work involved, but it's also a lot of fun and you really learn a lot
by doing it, since you need to configure every single aspect of the
system. This forces you to read a lot of manuals on how to configure
various software. It also gives you total control over your system
(well, that's the idea). You know exactly what software is installed,
how it is configured and where all the configuration files
reside.
Yes, Linux From Scratch is primarily about learning. Although the final
product can indeed be used as a distribution in its own right, the road
that one has to walk in order to get to the destination is too tedious
to turn it a regular routine. Installing Linux From Scratch is even
harder than installing Gentoo: there is no Portage to do the hard work
and all compiling has to be done with the classic UNIX tools of
configure, make and make install. But this
is where the educational value of Linux From Scratch manifests itself.
The process is possibly the most practical way to learn about every
detail regarding file structures, processor optimizations,
configuration files, security matters and thousands of other issues.
How much would you pay for a commercial Linux training course? Linux
From Scratch is a great resource which will not only teach you the very
basics of Linux, it will do so in a most entertaining way, all for
free.
If you decide to embark on this experience, consider these
prerequisites:
- Make sure that you have an existing Linux installation on your hard
disk. Any recent distribution will do, as long as it is complete with a
GCC compiler and relevant development tools.
- Download the LFS packages. All the required LFS packages can be
downloaded from LFS mirrors, either individually, or as one complete
tarball. Alternative methods using P2P networks or a wget script are
also available.
- Download the LFS book. The LFS book contains around 200 pages and
can be downloaded in HTML or PDF formats.
Although trying to absorb 200 highly technical pages split into 9
chapters might sound like a lot of hard work, the truth is that a great
deal of the book consists of reference information, such as package
descriptions and listings of program files and their dependencies. The
preface and the first chapter can be skimmed over - they contain little
beside a foreword, acknowledgment, conventions, changelog and other
general information. Chapter 2 explains how to create a new partition,
format it with an ext2 file system and mount it. Chapter 3 lists
packages needed to build LFS, while chapter 4 details the final
preparations before the actual build, inclusive of setting up the build
environment.
The real meat of the book starts in Chapter 5, which contains
instructions about compiling and installing a minimal Linux system. At
this stage, all compilation is done with tools "borrowed" from the host
environment, but with static linking to system libraries to gain
"independence" from the host system. This will ensure that the newly
compiled tools still work in a subsequent, "chroot-ed" stage. The
compile process starts with GNU Binutils and continues with GCC, Linux
header files, Glibc, Tcl, several essential GNU utilities, and Perl.
After installing Glibc, both Binutils and GCC have to be recompiled for
the second time to link them against the new Glibc. The compiling of
most packages will only take a minute or two, with the exception of
Glibc and GCC, which will take a lot longer. However, the time it takes
to compile the packages can be utilized for reading the relevant
sections in the book, which provide detailed information about such
interesting matters as the purpose of the many available GCC compiler
flags and other related topics.
Chapter 6 starts with mounting the proc and devpts
file systems, followed by a chroot into the newly compiled
base LFS partition. The next step is to create a standard UNIX
directory structure. If you are fairly new to the world of Linux, this
is a great chapter to learn about file permissions, passwords, users
and groups, log files, and also about creating devices in the
/dev directory. Next comes a detailed explanation on compiling
Glibc, including notes on locales, how to configure the dynamic loader,
and a list of commands provided by Glibc. A very useful chapter indeed!
In order to enable dynamic linking to system libraries, all
applications compiled in the previous chapter need to be recompiled
here for the second time (or, in the case of Binutils and GCC, for the
third time). The remaining system packages will also be compiled in
this chapter. Interestingly, beside GCC 3.3.3, the book also recommends
installing GCC 2.95.3, which will be used exclusively for compiling the
Linux kernel; the well-tested older compiler is said to be more
suitable for building a rock-solid kernel than any of the new GCC 3.x
series.
The full Linux kernel is finally compiled in chapter 8. However, to get
there, one still needs to go through the short, but important chapter 7
- another invaluable section of the book providing all the necessary
bootscripts and filled with information about setting up the system
clock, the syslog daemon, and networking. The kernel compilation
chapter does not deal with kernel configuration issues; it merely
provides instructions to compile a default kernel, with a suggested
alternative of copying an existing kernel configuration file from a
known working system. The very final step of the book is to configure
the Grub boot loader (previous versions of LFS used lilo, but version
5.1 switched to Grub) to make the newly compiled Linux system bootable.
Completing all the steps in the book will probably kill a whole weekend,
but besides the freshly acquired knowledge and experience, the brand
new Linux system on your hard disk is very bare-bones and not
particularly useful. So how can you make it useful? By moving on to the
next book - the 413-page Beyond Linux
From Scratch (BLFS). This is a priceless resource with detailed
instruction on how to compile many common applications, including
essential utilities, server packages (Apache, MySQL, Samba...), desktop
environments (XFree86 + KDE, GNOME, XFce...), OpenOffice.org,
multimedia and printing packages, and many other open source
applications. At this stage, you'll probably start craving a binary
Linux distribution, one that can be installed and is ready to use in 20
minutes. But even if you don't plan on further package compiling, the
BLFS book is a great reference for those moments when you do need to
compile applications, with many tricks, workarounds and guidelines.
Linux From Scratch is a wonderful project. It should become a compulsory
reading material for all Linux training courses, and something that
every Linux enthusiast should complete at least once. This would also
create another interesting side effect: people who tend to be quick in
expressing dissatisfaction on the distributions' mailing lists and
forums would probably show a lot more respect for the developers.
Installing a ready-made distribution is a trivial task. Building up a
set of 4 CDs containing a stable, secure and reliable operating system,
plus thousands of applications, is most definitely not.
(
Log in to post comments)