Tuesday, 6 April 2010

Gentoo, sweet dream or a beautiful nightmare?

The Gentoo penguin, the fastest underwater swimming bird capable of reaching speeds of 36 km/h or 22.3 mph, but in the world of Linux Gentoo is another distribution with some very interesting differences.


Your average distribution consists of many software packages which have already been compiled from source and ready to install.

The distribution vendor is responsible for compiling all the software packages from source and grouping it together to create the distribution you download.

This also applies to software updates, the distribution vendor compiles the updates from source and stores it on a server ready for users to download.

One big disadvantage with this approach is all the software packages are compiled with very generic options and optimizations so that they are compatible on as many systems as possible.

As a result performance is sacrificed in favour of compatibility.

Another problem with your average distribution and I quote from the Gentoo Manual,

"Most distributions compile their packages with support for as much as possible, increasing the size of the programs and startup time, not to mention an enormous amount of dependencies"

Unfortunately this is standard practice with most distributions.

Is there an alternative?

Distributions could be provided in more flavours giving the user the choice to download a version which has been specifically compiled with optimizations for their processor architecture only.

Typically with your popular distribution you can download either an x86 or x86_64 bit version but why not provide more specific choices within these categories?

Hang on a minute, how many different processor types are there?

A quick look at the GCC (compiler program used to compile most Linux source code) documentation reveals, quite a bit. I count 39.


We can therefore conclude the practicality of providing more specific fine tuned distributions and software packages is far from practical.

The distribution vendor would have to provide 39 different operating systems to download and also maintain a software repository containing 39 variations of the same piece of software for updates.

In addressing the second issue of compiling programs with much support as possible, given that all code is compiled in a generic fashion it just makes sense to follow the trend of compatibility and to support as much as possible.

So is there an alternative, at this point you would be right to think no.

However you would be wrong. There is an alternative and it is called Gentoo.

Gentoo addresses the above issues because it is not supplied in a ready to use compiled state.

Gentoo is a source based distribution.

When you download Gentoo, you get a live installation setup CD / DVD. You then have the joy of setting up your system from near enough scratch.

Part of the Gentoo install process involves compiling all software packages and the kernel from source!

Prior to compiling, you have to setup the GCC compiler options meaning you can tune the compiler to compile all source code in a way that is optimized for your processor.

You can also set various USE flags used to compile software, so you can decided overall what your software should support and avoid doing what most vendors do, to make software packages support as much as possible.

Sounds cool?

It does indeed but there are very big disadvantages with the Gentoo approach.

It is very time consuming, compiling a complete system with a graphical desktop environment can take a number of hours or days depending on your processor and available memory.

You must know what you are doing.

And whilst not a disadvantage, does the optimization benefits justify going through this long process, are the speed improvements worthwhile?

There is only one way to find out.

I have never tried Gentoo before, so this will be quite interesting. Is it really as good as some people say?

After consulting the manual I proceeded to download and create the Gentoo 10.1 installation DVD.

Booting from the DVD takes you to a KDE desktop environment. I used Konqueror web browser to open the Gentoo manual and followed the procedure.

Was it straight forward?

Gentoo provide enough documentation and a good wiki but it is assumed you have the relevant experience and/or knowledge.

Going through the Gentoo install process requires using the terminal with root access. The live DVD does not allow you by default to use the KDE environment with root access but does default to root access in the virtual terminals.

So if you want to consult the manual online in KDE and use a root terminal you have to keep switching between a virtual terminal and graphical environment (KDE).

However the way around this is to enable root access in the KDE desktop environment so you can have Konqueror open to view the manual and use the KDE Konsole to setup your Gentoo install.

I simply typed in the virtual terminal, passwd. It will ask you to enter the new password for root.

Now switch back to KDE (Ctrl-Alt-F7) and you can become root using the password created above. As a result you can view Konsole and Konqueror side by side.

And that's an example of where knowledge is assumed. Would I even have thought about this as a newbie?

Another benefit due to the above is that rather than using command line to create your disk partitions you can now use the Kpartition application on the Gentoo DVD, which is a nice GUI interface.

Less typing on the keyboard means you are reducing your chances of developing RSI.

Creating partitions

When is comes to setting up your disk partitions the manual uses the example of creating the following,

/boot (ext3)
/root (ext3)
swap partition

A more preferable setup would be to create a separate home partition as follows,

/root (ext4)
/home (ext4)
swap partition

I went for ext4 because it is default for most recent distributions and better than ext3 in terms of design, performance and reliability.

As a result of choosing an ext4 filesystem, I had to enable ext4 support in the kernel.

Compilier options

The most interesting part for me during the install process was setting up the compiler options. As a first time Gentoo user I have never done this before and had to spend a bit of time researching GCC.

If you want your Gentoo system optimized for your system the compiler options must be selected accordingly.

With my current system featuring an AMD Athlon II X2 250 AM3, I worked out the appropriate -march type was amdfam10.

Here are the options I used.

CFLAGS="-march=amdfam10 -O2 -pipe -fomit-frame-pointer"

Kernel Configuration

Configuring the Kernel is something I have done many times. Mainly to tweak things or just experiment. In my early days with Linux I set myself little missions :-)

How small can I make the kernel without having any negative impact on my system, what happens if I do this, what does that do.

I remember during Fedora Core 4 I was playing around with Dazuko and AntiVir, which required setting the default Linux capabilities in the kernel as a module in order for Dazuko to work. It may sound so easy now but back then it was a great learning experience.

Back to Gentoo, the manual states you have two options regarding the configuration of the kernel. First, manual configuration and second is using GenKernel.

You can guess I went for a manual.

I left most of the kernel options to their default values as at this stage I am more concerned with getting Gentoo up and running rather than tweaking the kernel which can be done well after install at any time.

I did set the processor type and also noticed the kernel was set to compile with the option 'optimize for size' which means passing -Os to the gcc compiler. Not something I want, so this was changed.

After the kernel compiled, its just a case of setting up various things.

Grub, manual is safer

Again with the grub configuration I went for a manual approach, I have two hard disks in the system and wanted to ensure no mistakes.

After the grub configuration your Gentoo install is more or less complete.

Rebooting the system 'should' take you to your nice new Gentoo base system.

After my first reboot I noticed an error message about dchp cant find eth0 and no network module was present. I realized I must have missed out the appropriate module in the kernel configuration.

The great thing about this was I was able to quickly sort the problem by recompiling the kernel and updating the grub.conf to point to the newly compiled kernel a few minutes.

So what next?

As a desktop user a monitor displaying a black terminal isn't very useful. So we need to install a desktop environment such as Gnome or KDE.

During the install process you are asked to choose a system profile for your Gentoo system, I chose desktop.kde.

The profiles are geared towards making your system more tailored for a particular use, as in my case KDE and it sets appropriate use flags when compiling KDE and applications.

The first step to getting a working KDE environment is to install the X server which is the graphical backend for Linux and is used by desktop environments such as KDE and Gnome.

Consulting the Gentoo documentation provides much needed guidance.


Both those parts took a very long time, as everything is compiled from source. I would estimate the total time was 6 hours to compile.

I was quite excited when my KDE 4.4.2 compiled and install was complete.

All I had to do was create a new user account, type a few commands and login.

The first KDE 4.4.2 login, the big moment!

It was hard to assess if compiling the base system with optimizations for my system was faster or more responsive, there isn't much that can be observed apart from a blinking cursor.

I was hopeful that in a desktop environment such as KDE I would observe the benefits.

Sluggish and poor system response is something I have experienced on a number of distributions, past Fedora releases in particular (unless you disable SELinux) have been a bit sluggish although Fedora 12 seems quite acceptable.

Something Windows continues to do better than Linux, Windows 7 is the most responsive operating system on my PC and Laptop.

When I first logged in KDE 4.4.2 on my Gentoo system the first thing I noticed was how quiet my hard disk was. The loading was very minimal compared to other distributions.

Working with the GUI, clicking on icons and launching programs was quite responsive. More than I have ever experienced on any Linux distribution.

Overall I can feel the difference, the system is more responsive and the hard disk isn't loading as much. It is a pleasant feel.

However more needs to be done with my Gentoo install, currently there is a lack of applications. No K3b, Kaffeine, Amarok, Open Office...

I did also encounter some minor issues, the OpenGL performance in KDE was slow and I could not enable compiz. A quick Google searched revealed the solution posted on the Gentoo forums, 'eselect opengl set nvidia'

Is it worth using Gentoo over other distributions?

With Gentoo I like the following,

Every software package is compiled and optimized for your system

It does not run a crap load of services that someone else thinks should be running and runs what is needed for your system.

As above but with respect to applications, it starts with a minimalist approach and you have to decide what you want.

The kernel is lightweight by default

The system response is nippy

Extremely customizable and good documentation.

What I do not like,

Unpractical time consuming process

Whilst contradicting my earlier point about documentation, perhaps some more hints and tips could be included to help less experienced users.

You need to know what you are doing.

In addressing the what I do not like category, Gentoo is aimed for the experienced Linux user, and taking that into account the only real problem with Gentoo is its time consuming installation process.

But if you want optimized, responsive and total control then Gentoo seems like the solution.

To answer my question, would I use it over anything else?

Yes and No.

It is very tweakable, I like that but the time to setup vs performance is a big issue and has other consequences.

Compiling puts a high load on the processor.

On my Desktop PC I do not mind leaving it overnight to compile packages or updates. I can do so knowing nothing will go wrong as the cooling my custom built PC currently has is excellent and well up for the job.

My Laptop however, Gentoo is simply one way to shorten its lifespan. Over 6 hours non stop compiling will take its toll and is not something I am prepared to do.

OpenSUSE or Ubuntu would be more practical in this instance and I am happy to live without the performance gain Gentoo can provide.

I have seen many differing views on Gentoo, some say it is a complete waste of time, others say it makes no difference and some its the best thing since transistors.

As with anything Linux, its all about choice and using what your like.

Is it the fastest Linux distribution, available?

Well, with a name like Gentoo the developers believe this to be the case but from my point of view it is the fastest I have ever used in terms of system responsiveness and application load times.

After adding a few more applications, like Open Office, Opera and K3b, I did notice their start up times were quicker compared to other distributions.

Final thoughts

If you have the time, experience and patience then give Gentoo a go, it will be a good learning experience.

If not, stick with your current distribution or use something else as the speed improvements are small and for most people not worth the hassle.

Gentoo is like a high performance car, we like the performance but when you consider the more important issues like fuel consumption and maintenance, it may not be practical.

Screenshot of Gentoo 10.1 with KDE 4.4.2

Gentoo, a beautiful nightmare!