Saturday, December 17, 2005

Debian HOW-TO: Custom Kernel Compile

Last revision : February 23th, 2007

You want to compile your very own linux kernel ? No ? Well you should ! Here is a simple receipt.

The steps described below work for both Debian and Ubuntu.

So, read carefully.


  • Preparing the system

Note that I use sudo to get root privileges, refer to this tutorial for more info about that.

First install the required packages :

sudo apt-get install fakeroot bzip2 kernel-package libncurses-dev



Were you planning to compile as root ? That's evil, don't do it. Compile as a normal user : for that you have to put yourself in the src group. My username is mastah, so I type :

sudo adduser mastah src


Then you must logout, and log back in.


  • Getting the source

First you must download the latest kernel. Browse the Linux Kernel FTP server and download the latest kernel, or simply issue that command while you are in your download directory :

wget ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.20.tar.bz2
wget ftp://ftp.kernel.org/pub/linux/kernel/v2.6/patch-2.6.20.1.bz2



  • Configuration & Compilation

The work begins :

cd /usr/src
tar jxf /path/to/linux-2.6.20.tar.bz2


At this point prepare to apply the latest patch (or the one of your choice). Remember that patches are generally mutually exclusive : you can only apply one patch to the vanilla (generic) kernel. Some notorious kernel patches include : the realtime patches by Ingo Molnar, and of course the CK patches by Con Kolivas.

In this example we are to use the official 2.6.20.1 patch :

mv linux-2.6.20/ linux-2.6.20.1
cd linux-2.6.20.1/


Note that if we were to apply the CK patch, replacing 2.6.20.1 with 2.6.20-ck1 would do the trick.

Then test that the patch will apply cleanly :

bzcat /path/to/patch-2.6.20.1.bz2 | patch -p1 --dry-run


If everything outputs ok, then you can apply the patch for real :

bzcat /path/to/patch-2.6.20.1.bz2 | patch -p1


Use the configuration of your choice (I generally use Debian's kernel one) :

cp /boot/config-$(uname -r) .config


Then the fun starts.

To enter the kernel configuration utility, type :

make menuconfig



Some important points regarding kernel configuration, presented as examples :

Processor type and features ---> Processor family ---> (X) Core 2/newer Xeon
...use your specific CPU here.


Processor type and features ---> Timer Frequency ---> (X) 1000 HZ
...for a desktop machine, a high timer frequency is often ideal, as it will confer low latency. For a laptop, choosing a lower frequency will save battery power.


Processor type and features ---> Preemption Model ---> (X) Preemptible Kernel (Low-Latency Desktop)
...for a desktop machine, you can choose either Volontary Kernel Preemption or Preemptible Kernel. A fully preemptible kernel will have lower throughput, but quicker response time.


Kernel Hacking --->
...this refers to kernel debugging and other various options mainly useful to kernel developers : if you don't plan to do some kernel hacking, you can turn off all those features, as they make the kernel bigger (thus slower).


Device Drivers ---> Graphics support ---> < > Support for frame buffer devices
...you want boot time to be as short as possible, so why care about a boot splash image or fancy fonts in console ? So unless you need this, you can turn it off.


Device Drivers ---> Virtualization  --->  Kernel-based Virtual Machine (KVM) support
...a new feature as of Linux kernel 2.6.20. Be sure to also include INTEL or AMD specific module if you are to use KVM. Very useful feature for virtualization machines like QEMU.

The rest is only optional : setting IDE drivers, SATA drivers (if applicable) and main filesystem to Y (building them statically) will allow you to build a kernel without a RAM disk (initrd), thus speeding the boot process. You have to know your specific chipsets names (output of lspci) by which they are referred by the kernel team. Check the kernel documentation for more (in the /path/to/kernel/Documentation directory).

Finally, don't forget to SAVE.

Now clean the source tree :

fakeroot make-kpkg clean


Then build the kernel package :

fakeroot make-kpkg --append-to-version "<-suffix>" --revision "<revision#>" --us --uc --initrd kernel_image kernel_headers



  • Installation

Install the newly built kernel and its headers :

cd ..
sudo dpkg -i linux-image-2.6.20.1<-suffix>_<revision#>_i386.deb
sudo dpkg -i linux-headers-2.6.20.1<-suffix>_<revision#>_i386.deb


Replace <-suffix> with whatever you want (like -mykernel), and change <revision#> with a number (like the date, 23022007).

Using the --initrd (RAM disk, to preloads some required modules) parameter gives a working kernel with less efforts (you can build your kernel in an entirely modular way, so you don't have to tweak everything).

Everything is ready, you can reboot...

Make sure you boot into your new kernel!

>>> Read the full article

Wednesday, December 14, 2005

Debian HOW-TO: sources & extras

To get a good Desktop out of Debian, well you need some multimedia capabilities.

Mines come from Christian Marillat's repository, check out his homepage.

There are tons of repositories avalaible for Debian (most are for Sid, the unstable branch). The apt-get site has an extensive list.

If you have an ATI card and you're a Debian newbie, well you'll like this. It's the work of one man: Flavio Stanchina. His drivers work flawlessly, just follow the instructions, which are fairly simple (scary at first, but straight to point if you take the time to read them).

Mr. Stanchina's site his a very good alternative for those who want to keep things standard (no custom kernel).

I'm preparing a paper on how to compile a kernel for a Debian desktop machine in a few minimal steps. In the mean time, be sure to take a look at the "custom kernel compilation" section of this page.

Keep on hacking!

>>> Read the full article

Sunday, December 11, 2005

Propaganda

Debian GNU/Linux

How is it? Simply the best at what it does.

Debian has a hard reputation of being geek-oriented, of not being user-friendly. Ok. Maybe I don't know much about much (I've only used Debian since Sarge), but it doesn't sound true considering my personal experience with it.

Debian has always been good to me, and those words now sounds like music to my ears: apt-get, dpkg, make-kpkg. Debian doesn't fall in the trap of over-simplification. It has no does-it-all tools or does-it-for-you utilities. The secret is many little tools that do little things at near perfection. You can play with it, you can change everything about it, you can make it your own: never will it break.

I like everything about this operating system. For anyone looking for a stable yet very powerful OS, it really is the ultimate experience. And for all the hackers out there salivating about Gentoo, well you can hack Debian to the point of over-bleeding-edginess and it will never complain. Compiling a kernel is a breeze, installing packages from source is as easy as "apt-get -b source".

For anyone willing to learn Linux, Debian is just excellent.

Overall...
Turns me on: installer, package management tools & wide selection, stability
Makes me wanna switch to Ubuntu sometimes: out-of-date packages

>>> Read the full article

Debian HOW-TO: OpenOffice 2.0

With Debian Sarge comes OpenOffice version 1.1.3, though I much prefer the new version 2.0.

First, if you have installed OpenOffice 1.1.3, I suggest you uninstall it, for that use Synaptic or apt-get :

sudo apt-get remove --purge openoffice.org


Now, let's get to OpenOffice 2.0.

  • Prerequisite

You'll need to install Java first : here is a tutorial.

  • Installation


Download OpenOffice.org 2.0 for Linux from openoffice.org.

Install the required Debian/Ubuntu packages :

sudo apt-get install fakeroot alien


Uncompress the tarball :

tar zxf OOo_2.0.0_LinuxIntel_install.tar.gz


Navigate into the right directory :

cd OOO680_m3_native_packed-2_en-US.8968/RPMS/


Convert the .rpm packages to .deb (debian packages) :

fakeroot alien -d *.rpm


Now install those Debian packages :

sudo dpkg -i *.deb
cd desktop-integration/
sudo dpkg -i openoffice.org-debian-menus_2.0.0-3_all.deb


That's it!

>>> Read the full article

Debian/Ubuntu HOW-TO: Sun's Java

Last revision : April 28th, 2007

Installing Java from Sun is very easy in Debian.

Here is the simplest way. First a section for Debian Etch users, then the explanation for Debian Sarge.



  • Installation

On Debian Etch


On Debian Etch the installation is incredibly simple. On you made sure you have the non-free repository enabled, just type:

sudo apt-get install sun-java5-jre


For the Java browser plugin, you will the package sun-java5-plugin as well:

sudo apt-get install sun-java5-plugin


For Debian Etch, nothing more is needed.


On Debian Sarge


On Debian Sarge, as no pre-build packages exist, we need to create our own. Still, quite simple.

Browse to the download section of java developer's site.

Click on Download near Java Runtime Environment (JRE) 5.0 Update 11

Click on Accept License Agreement

Click on Linux self-extracting file and download the file.

Install the needed packages :

sudo apt-get install fakeroot java-package


Build a custom package using the java installer :

fakeroot make-jpkg jre-1_5_0_11-linux-i586.bin


...answer all the questions with the default answers.

Install your custom package :

sudo dpkg -i sun-j2re1.5_1.5.0+update11_i386.deb


That's it, your Mozilla or Mozilla Firefox browsers will now be java-enabled.


  • Tips

Test your Java Virtual Machine directly on Sun's website


You can verify that Sun's Java is effectively the default Java on your system :

java -version


Which should output something like that :

java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)


If that is not the case, then make it default with this command :

sudo update-alternatives --config java


and choose JRE.

>>> Read the full article

Debian HOW-TO: Sudo

In general, to perform any operation that requires root privileges, I like to use sudo, which gives root privileges temporarily. So here is how to add yourself to the sudoers group:

su


Then you type the root password (which will not appear as you type it).

Once logged as root, type:

apt-get install sudo


to make sure the required package is installed.

Then configure it:

visudo


At the end of the file, you will see:

# User privilege specification
root ALL=(ALL) ALL


just add, at the end a line like that:

mastah ALL=(ALL) ALL

mastah being my username.

Save the file, and you are done. You can log off as root:

exit

>>> Read the full article

And it looks good

Installing Debian GNU/Linux as become very easy since the release of Sarge.

The simplest way to do it, if you have a nice and fast internet connection, is by using the Netinstaller.

You can view all your installation options here.

>>> Read the full article

Debian GNU/Linux

I use Debian GNU/Linux, version Sarge (3.1).

My desktop environment of choice is Gnome, though I do appreciate KDE as well.

Why GNU/Linux?

At first I was extremely skeptical, but wanted to try something new. It came to my attention that Linux was getting more and more mature, and I've got to thank for that my friend Matt.

Well, after a few months of experimentation with many Linux distributions:
- Debian Sarge (stable)
- Debian Etch (testing)
- Debian Sid (unstable)
- Kubuntu 5.04/5.10
- Ubuntu 5.04/5.10
- Vector Standard edition 5.1
- Mandriva 2005
- Fedora Core 4
- Arch Linux Wombat 0.7
- Damn Small Linux 1.5/2.0
- GeeXbox 0.98.7
- Knoppix 4.02
- Elive 0.3
- and a few more.

Of all those, it finally came down to Debian Sarge.

What I like about it:
- by far the most stable OS I have ever used
- extremely easy to customize to your needs (apt-get & dpkg)
- never-ending choice of binary packages

What has been sacrificed to achieve those good points:
- the binary packages are sometimes a little out-of-date

I want to thank all the Debian GNU/Linux developpers for the incredible OS they deliver, release after release.

>>> Read the full article