Install Gentoo for kernel hacking

October 24th, 2010 mysurface Posted in emerge, gentoo | Hits: 189727 | 7 Comments »

I am curious about what are Linux kernel do? Many years ago, due to the tedious steps to compile the kernel, I give up dive into it at the very beginning stage, which is compiling kernel. But recently this urge come back to me. I started to wonder whether is it exist a Linux distro which provides kernel build environment.

I came across a forum (lost track of the link), someone mention in fact Gentoo is a good candidate for the kernel build. As simple as emerge the kernel source, and you will have the latest kernel source code under /usr/src/linux.

emerge gentoo-sources

Installing Gentoo is not like installing Ubuntu/Fedora/Suse, where you can clicks the way and get a fancy desktop. I don’t want a fancy Gnome/Kde, what I want is a text console, which allows me to learn and hack the kernels, therefore Gentoo came as a charm for me.

Gentoo Linux is a distro that gives you the best optimized system, best performance. It sounds like the best distro for you isn’t it? The reason why Gentoo can be so optimized and performance wise competent because you have to compile everything including kernel. emerge is a command that helps you download the source codes, resolve dependencies, compile and install it right for you.

The challenging build steps comes with a very details installation guide, you can start with it by reading Gentoo handbook.

I create an image on VirtualBox, network setting attach to NAT. under Advanced option Adapter type set as virtio-net. The reason I choose virtio-net as the adapter type, because that is the only Ethernet kernel module available on the Gentoo minimum live CD which VirtualBox (version 3.2.2) could provide.

I need to enable virtio as kernel module in kernel config, refers to the live cd, there are few kernel modules to enable. virtio, virtio_ring, virtio_net and virtio_pci.

In order to have a broaden view on console, I enable uvesafb. You can follow the guide here. It giving me problems that, no matter how I set my video option, I can only see half of the screen> Fortunately, I found some guides for Gentoo under VirtualBox.

Remove consolefont from boot runlevel

rc-update del consolefont boot

Replace video option:


For the fully customized OS like Gentoo, it is important to know the various configuration files. Here I wanna highlight some of the important one.

Mount Mapping table: /etc/fstab
This is the common one, to configure the mounting table, you have to edit this file.

Grub Bootloader config: /boot/grub/grub.conf
This is where you adding your kernel entries as your boot option. Video option is done here too.

Make config: /etc/make.conf
Installing package means compiling, to optimizing your build, defines your setting here. Portage related variables can define here too, such as GENTOO_MIRRORS and USE.

Kernel Modules Autoload: /etc/modules.autoload.d/kernel-2.6
You can define your extra kernel modules to autoload while booting up.

List of available kernel module installed.

find /lib/modules// -type f -iname '*.o' -or -iname '*.ko' | less

Network config: /etc/conf.d/net
Define your static IP or dhcp over here.

There are a lots more yet to discover for me, at least for now I am happy with Gentoo ;)

Hope you have fun too.

7 Responses to “Install Gentoo for kernel hacking”

  1. Nice blog. I will back soon as posible. See you leater.

  2. Just wanted to say this Blog is in my rss you rock.. Cheers,

  3. This design is spectacular! You most certainly know how to keep a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Great job. I really loved what you had to say, and more than that, how you presented it. Too cool!

  4. Excellent

  5. Thank for Information. I will back again. Thank :)

  6. International Real Estate portal TOP-CASA provides users the best choice of resort property, publish advertisements for the sale and rent of luxury apartments, houses, flats, villas. spain property

  7. Find The Best information about: christmas tree skirts, fiber optic christmas tree, spode christmas tree. christmas stockings