Linux From Scratch: a recipe for system

[ Monday, 12 May 2008, Keyto ]


Every free software enthusiast probably already knows that distrowatch.com, created by Ladislav Bodnar, is a great source of information on different open source operating systems. We can pretty much admit that every respected distribution based on Linux or BSD is at least mentioned on his website. You can find there descriptions of systems, starting from those small and fast ones, to the enormous distributions filled with packages that even the actual creators of those systems wouldn’t even think of. For instance, lets take DSL which “weights” only 49 megabytes or the newest DVD version of Slackware that that takes up to 3.7 gigabytes. Debian, well, that’s definitely a biggie. It takes up 3 DVD’s, which adds up to 12.9 gigabytes of packages ready to get installed. GoboLinux – fits on one CD, “weighing” 640 megabytes and finally Linux From Scratch Distribution – one PDF file, with over 250 pages….

Dragonia Magazine

One who decides to start his adventure with GNU/Linux system, usually goes with popular distributions. Then, after downloading the image and burning it, finally installs the system, in which the installation and configuration process was made easy by the authors. This allows the user to comfortably perform and finish the installation. More experienced users often decide to go with distributions built from source. Those include: Gentoo, and its less popular “fellas”: Lunar, T2 SDE, Sorcerer or Source Maga. These distributions, unlike the popular ones, allow you to build your own system from source. Knowing this fact, we can definitely say that Linux From Scratch counts as a special edition here. It’s a book (actually a few books) on how to create your own GNU/Linux distribution. Right now, there are 20 people working on this project. And of course, mentioning Gerad Beekman, the creator of this project, is a must.

The main parts of this projects are:

  1. Linux From Scratch (LFS) main book, includes the procedure of creating the base system.
  2. Beyond Linux From Scratch (BLFS) shows you how to enhance your system.
  3. Automated Linux From Scratch (ALFS) tool used to optimize the work in LFS and BLFS.
  4. Cross Linux From Scratch (CLFS) info about creating systems for different architectures.
  5. Hardened Linux From Scratch (HLFS) describes the process of securing our system.

LFS

As mentioned above, LFS shows us how to successfully compile a working system, but what does a working system actually mean? Well, it’s a complex environment that allows us to compile and install software. We basically get our own GNU/Linux distribution, working only in command line mode, that includes basic applications, such as a gcc compiler, primary editors (vim, sed), perl interpreter , and the manuals.

What’s next? We’ll talk about that in few moments, but first, you’re probably asking yourself: How much does it cost to create such a system? Well obviously, there’s no money involved, although time will play a big part here. It usually depends, on the speed of our machine, and the person working on the system. As a matter of fact, compiling will not even take half of time of the whole process, but even though, finding out more precise timing for this project wouldn’t be a bad idea. This will help you decide whether to go with it, or just let it go. To give you an overall image of this process, on a P4 / 3GHz / 1GB RAM computer, it will take about 10 hours, where about half of this time will be used up by the compiler. So on a rainy day, during a weekend, why not just give it a shot? Although, don’t forget that thanks to LFS you will only get the base system. This means, no GUI, no Firefox, and of course no OpenOffice.org. To make our system more functional you can use the second tome of LFS book, which is BLFS.

LFS

What for?

At first, you might think that LFS is a set of books created only for computer geeks and IT professionals. It is pretty much ensured that a regular PC user will not go with building a system from scratch, if he has many other, ready to use distributions. This is understandable, but if it comes to LFS, the whole concept just changes, because it’s a guide written for everyone, who would want to expand their knowledge about GNU/Linux systems. It’s not an easy way though, therefore it’s not the best thing for beginners, but on the other hand, this type of “exercise” is much easier than you might think. You don’t really have to know how to program or how systems are built. All you’ll need is some good knowledge of system administration, basics in compiling programs, couple megabytes on your hard drive, some free time, and the will of learning the system inside out.

We have to remember though, that there might be times were someone’s help could be needed. But if building the system form scratch will be only for learning purposes, than whole process doesn’t really have to be a success. You can learn a lot by going over only certain parts of this guide. That’s why even an unfinished project will help out in exploring your knowledge. Other than that, there are many other reasons to try out LFS. A good example here is creating a system for a special purpose, (the author, in the beginning of this guide, talks about a 5-megabyte server), embedded system, or for instance a system designed for a given machine and for one’s needs – this type of a system can be really fast and stable.

If we don’t have the time and the will for compiling our own system, downloading the LFS guide still wouldn’t go to waste. By studying this guide, we can learn some general and very valuable information about GNU/Linux, and get the overall basics of any computer system. The book also includes descriptions of packages, scripts, and — the most important thing — components of a system, and their job.

Warning – Construction Area!

OK, we finally decided to build our system, but the question comes: How can we do it the easiest way? First, to build our own system using LFS, we need an already working GNU/Linux system, since our new OS will be build in Linux environment. It can pretty much be any distribution that satisfies the requirement mentioned in the beginning of the LFS guide. Well, what should we do if we don’t have that kind of a system? Thanks to the authors, we can use an LFS LiveCD. It can be found on the official LFS website, in ISO image, that includes a full, compatible system, LFS and BLFS books in HTML format, source packages, required scripts and basic tools. So basically, after burning the image, we have everything we need to build our own system.

Now, we might still encounter some problems such as: What should we do if we’re not advanced users and we don’t want to damage our current system or maybe what if we don’t have enough space on our hard drive? And, we can’t forget about compiling time, either! When it comes to installing software, many users don’t go the longer way, the “compile from source” way, mostly because they don’t want to, or perhaps they don’t have access to the computer for certain amount of hours. The answer for those problems is — virtualization! As of this moment, there are many good programs for this job, such as: VMware Server, Innotek VirtualBox or Qemu. Now all you gotta do is install one of those programs, get a ISO image of LFS LiveCD, configure your virtual machine, and you can then, safely test your system in a nice, virtual lab. For less advanced users, the easiest program would be VirtualBox. It’s easy to use and available for many different operating systems. The good thing about virtualization is that we can “freeze” our working system pretty much any time. Thanks to that feature, we can compile our system by parts whenever we want. To help you out in dividing your building process into a couple of parts, you can use estimated compile time for required packages. In their books, authors use a made-up unit – SBU. Since they were not able to precisely get the compiling time for every machine (they would probably had to make a huge list of every computer in the entire world to do so), they’ve used the following method. One of the first packages we have to compile is binutils. If the time taken to compile it is equal to 1 unit of SBU, than the timing for other packages will be more or less proportional. So if binutils compiles in 1 minute, then coreutils, which takes about 0.5 SBU, will compile in 30 seconds, etc.

LFS

Some goodies for the ending:

GNU/Linux without GNU

The GNU/Linux makes up a Linux OS and GNU software. That’s why we call it that way. You probably know that GNU system was created in 1993 and it was supposed to be a stand-alone system. Although, after all the GNU software became stable, there were many problems with the operating system, and more specifically with the Hurd kernel. If we take a look at the list with software required to build LFS, we can notice that most of those programs come from Free Software Foundation. Anyway, is it possible to build and run LFS without this software? Definitely! Want some examples? Well, there you go: One of the base components of our system is a C compiler. Using it, we can build a fully functional system. Of course, the C compiler and its required libraries are a standard part of the GNU project. Cool Fact: Eric Anderson is developing the base library (libc) for C which also is a part of the GNU project. His library, named uClibc, is used mostly in embedded systems. Why? It is much smaller than its older brother, and works on pretty much every program that cooperates with the “original” libc. An interesting GNU program for a regular user is BusyBox. Its authors call it the “universal penknife for embedded Linux systems”. BusyBox is actually a program that has functionality of almost all the coreutils packages (Coreutils is a collection of the most frequently used command line programs in Linux, like: cat, chown, mv, uname, who, cp, ln). The interesting thing about BusyBox, is that it “knows” what should be used in a given situation. In other words, it knows for example when to become a text editor, and when to copy files. In depends on the actual name that we use to run the program. So for instance, if we change the program name from Busybox to vim – it will become an text editor, if we change it to ln – it will be used to create symbolic links, and the good about this is that we don’t have to create backups. All we need to do is to create a copy of it using the “ln” command, which will allow us to link it to the program we want to use. Just to let you know, the “ln” tool, is one of the most useful and powerful utilities for Unix systems.

GNU/Linux without… Linux

Now, lets think about GNU/Linux without Linux. Is it possible to build a GNU/Linux without Linux? Well, going back to things I mentioned above – the GNU system is supposed to natively works with the Hurd kernel. So it’s kind of a rhetorical question to ask. Anyway, although there’ve been many attempts to run a GNU system, using the Hurd kernel, even a long time after the introduction of Linux, they don’t really work, at least not yet. For those keen on trying the experimental stuff — there’s a Debian GNU/Hurd project going on, that builds a Debian distribution on Hurd, and a couple alpha-stage systems with SunOS (Solaris) kernel in progress, the most important ones being: SchilliX, BeleniX and NexentaOS. But we’ll leave all that for another article :)

Mini Dictionary

Operating System — the general definition states that it is a program, which constantly works from the moment we start our computer to a complete shutdown (or restart). All other programs are application programs. We can actually put an equals sign between the word “kernel” and the technical meaning of the word “operating system”.

Nowadays, we can also call a working environment by using the term “operating system”. That is why, we can say that Linux counts as a full system, although this name also applies to the kernel. In this article I used the phrase “operating system” to describe a kernel, and a “system” to describe the fully operational environment.

Further reading

  • LFS’ website – http://www.linuxfromscratch.org/
  • Distrowatch – http://distrowatch.com/
  • VirtualBox – http://www.virtualbox.org/
  • GNU – http://www.gnu.org/
  • BUSYBOX – http://www.busybox.net/
  • uClibc – http://www.uclibc.org/
  • Embedded systems – http://en.wikipedia.org/wiki/Embedded_system
  • Debian GNU/Hurd – http://www.debian.org/ports/hurd/

Translated by: ColdX

Subscribe to RSS feed for this article!

11 Comments

fold this thread Morten Juhl-Johansen Zölde-Fejér  Wednesday, 14 May 2008 o godz. 11:23 am #  Add karma Subtract karma  error

Tempting, one must admit. If only I had the time to play with it.

(Comments wont nest below this level)
 
fold this thread Rob  Friday, 16 May 2008 o godz. 8:56 am #  Add karma Subtract karma  +1

I’m going to try it this weekend!

(Comments wont nest below this level)
 
fold this thread Leon  Friday, 16 May 2008 o godz. 12:45 pm #  Add karma Subtract karma  +2

Many people think that LFS is not usable as a everyday system but I think that’s not true. Unlike other distributions, LFS allows one to customise the system completely to the person’s needs, right down to the bolts and nuts. This simply means that whatever one wishes to do, he can do it on LFS. Not only things like X, OpenOffice and Gimp, but beyond.

I am sure there are people running Ubuntu who sometimes wish to do things differently then what the distribution intended for them. But once they start meddling about the scripts and the source code they break compatibility with the next upgrade version of the distribution or other parts of the distribution and a lot of issues come in. This result in huge headaches and frequent computer re-format. Quite the irony since we wanted to step away from that experience (read: Windows).

By building and running LFS one learn more and more everyday so that the amount of power that can be harnessed from Linux increase all the time. Complete control allow us to break things and fix things and we know for sure what is going on, instead of just apt-get and forget about everything else.

(Comments wont nest below this level)
 
fold this thread yoander  Friday, 16 May 2008 o godz. 4:50 pm #  Add karma Subtract karma  +1

We can’t do a lot with Linux Kernel only. We need the GNU tools in order to have a fully free functional OS; for example: cat, chmod, ls, gcc are parts of The GNU project and the others tools have been influenced by it.

GNU can run in BSD kernel.

See:


Debian GNU/kFreeBSD


Debian GNU/NetBSD

(Comments wont nest below this level)
 
fold this thread zenboy  Friday, 16 May 2008 o godz. 5:26 pm #  Add karma Subtract karma  +2

Some things that have been left out, maybe due to the space requirements of this article:

1) Cross LFS is not LFS. It is a far different project with much heavier work done in the background. CLFS supports more than 10 different architectures and combinations of them. It can be built from within one architecture, to another. The leadership is different, the goals are different, the bar is raised. CBLFS is another CLFS project for having more packages as well.

2) DIY-Linux is being left out (http://diy-linux.org). DIY-Linux is Greg Schaffer’s work that has started as a more usable system targeting people with far greater expectations than mere copy paste of commands for producing a “system”. DIY-L has been multiarch for a while, as well.

3) Changes done in CLFS, DIYL are being constantly backported to LFS.

Just my 2c for readers who would like to get their feet wet.

(Comments wont nest below this level)
 
fold this thread Matthew Anderson  Thursday, 20 May 2010 o godz. 7:45 pm #  Add karma Subtract karma  +0

For me, the best operating system is Linux because it rarely hangs.-.”

(Comments wont nest below this level)
 
fold this thread Blake Butler  Monday, 13 September 2010 o godz. 7:20 am #  Add karma Subtract karma  +0

with regards to PC operating system, i love Windows XP and Linux`,:

(Comments wont nest below this level)
 
fold this thread Caramoan   Wednesday, 13 October 2010 o godz. 10:58 am #  Add karma Subtract karma  +0

the best operating system is always Linux, after Linux it is Windows XP. Vista sucks,*;

(Comments wont nest below this level)
 
fold this thread Laser Marking Devices %0B  Monday, 20 December 2010 o godz. 8:55 pm #  Add karma Subtract karma  +0

there are many different operating systems but of course i would still prefer to use linux for stability ;-,

(Comments wont nest below this level)
 
fold this thread Kasino  Wednesday, 13 April 2011 o godz. 8:12 am #  Add karma Subtract karma  +0

Hello there, You have done a fantastic job. I will definitely digg it and for my part suggest to my friends. I am confident they’ll be benefited from this site.

(Comments wont nest below this level)
 
fold this thread Kim Kardashian dating  Saturday, 16 April 2011 o godz. 11:12 pm #  Add karma Subtract karma  +0

hey, illustrious blog on fatlike loss. said helped.

(Comments wont nest below this level)
 
Name (required)
E-mail (required - never shown publicly)
URI

Adjust field size: shrink | enlarge)


You can use simple HTML in your comments. Some examples are as follows:
  • A hyperlink: <a href="polishlinux.org">GNU/Linux for everyone!</a>,
  • Strong text: <strong>Strong text</strong>,
  • Italic text: <em>italic text</em>,
  • Strike: <strike>strike</strike>,
  • Code: <code>printf("hello world");</code>,
  • Block quote: <blockquote>Block quote</blockquote>

About the Author

Keyto

Keyto is a computer engineer living in Poland. In free time he likes to write longish stories about GNU, Linux and its users :)

New AdTaily ads!

Are you a film buff?

film buffs community, movie recommendations and reviews

RSS: Comments

You can follow the comments to this article through a special channel RSS 2.0 .

Related articles: Linux

 more »

PolishLinux Top Content


Become our fan on Facebook!

PolishLinux.org on Facebook

Follow PolishLinux on Twitter!

Follow polishlinux on Twitter

Google Ads