We are going to use the kernel sources from the funtoo git repository.

+

The source you use on your system is up to you. For a laptop or desktop system, the following are recommended:

−

+

−

The source you use on your system is up to you and your needs.

+

−

For a laptop or desktop system, we recommend the following:

+

−

+

* '''{{Package|sys-kernel/pf-sources}}'''

* '''{{Package|sys-kernel/pf-sources}}'''

* '''{{Package|sys-kernel/ck-sources}}'''

* '''{{Package|sys-kernel/ck-sources}}'''

Line 42:

Line 38:

* '''{{Package|sys-kernel/sysrescue-std-sources}}'''

* '''{{Package|sys-kernel/sysrescue-std-sources}}'''

* '''{{Package|sys-kernel/debian-sources}}'''

* '''{{Package|sys-kernel/debian-sources}}'''

−

+

{{Note}} If you are unsure for now, use sys-kernel/gentoo-sources. That's always a safe bet for a general system.

−

Please, have a look in the ebuild description, look onto their homepage and take the one that suits you best!

+

−

If you are unsure for now, use sys-kernel/gentoo-sources. That's always a safe bet for a general system.

+

−

+

−

It is not a problem to have various kernels installed parallel, so go on with any one of them.

+

−

+

−

I am going to use the sys-kernel/pf-sources now, as I already had the gentoo-sources installed.

+

== Prerequisites ==

== Prerequisites ==

Revision as of 02:05, January 11, 2014

Setting up a proper kernel yourself - lean, mean and tailored to your hardware, is the challenge by which a linux user can graduate to becoming a Funtoo knight ;-)

Even though many of us are using enterprise-ready kernels in datacenters, there is almost nobody who hasn't at least considered building a kernel for his laptop / PC.
We are showing here how an intermediate Linux user can use an alternative to the standard beginners "genkernel" approach, to compile a custom kernel, in a relatively speedy and easy set up.

Minimum Requirements

Understand the command line

Know where the kernel files are located

Assumptions

You start from an installed Funtoo system on the disk, or at least, you are on stage3 in a chrooted environment from a live cd, following somehow the Funto Installation Tutorial.

In this case we are building a kernel that is booting root in LVM over encrypted LUKS container.
If you don't have this setup, don't worry, you just don't need all the modules, but everything else is similar.

Getting ready to start

First there is the decision which linux kernel sources we need.
There are plenty of them in the repositories around, often it is not easy to distinguish between them.

I would always trust my distribution of choice and take what is has to offer - and funtoo has a lot to offer!

I really do recommend (especially if it is your first time) to build a debian-sourced genkernel like described in chapter 5 "Using Debian-Sources with Genkernel" in the Funtoo Kernels Tutorial.

From there you should have a running system booting nicely from your own build (just little bit bloated) kernel. This is more than you can expect from any other ready to go distribution.

Note

{{{1}}}

We are using RedHat's dracut in order to build a nice initramfs (containing all the necessary tools and extra drivers our kernel might need to start the system). Although dracut is the way to go, more sophisticated and not as buggy as gentoo's genkernel approach, more and more funtoo geeks start using slashbeast's better-initramfs, which we will cover at the end of this howto! So after having set up a genkernel from debian or gentoo sources we are going to build a kernel with either (or both) dracut or/and better-initramfs. So gentoo sources with genkernel is always my backup if anything is not working correctly on my system. For the slightly more geeky approach with my own initram I am using pf-sources, ck-sources or any other more or less heavily patched sources.

Let's go!

Kernel Sources

The source you use on your system is up to you. For a laptop or desktop system, the following are recommended:

Building the Kernel

Initramfs, or not?

The reason to build a kernel with an initramfs is mostly for interoperability (e.g. live-cd's) and special features like an included busybox, ssh, etc. But mostly, and that's why we are doing this here now, to have a proper kernel up and running quick'n dirty in a reasonable time without fighting hours and days until a more or less exotic hardware is perfectly run by the kernel.
After having a proper basic kernel running with the help of an initramfs, I really recommend you to go a step further and build a true kernel with all features includes without an initramfs. But this could be pain in the ass and very time consuming - so we do it the funtoo way here - at least in the second example when we stick to better-initramfs instead of Red-Hat's dracut.

Option one: Initrd with dracut

To build the initrd, we just execute:

# dracut -f --fstab --xz /boot/initramfs-3.2.6-pf.img 3.2.6-pf

Generally, this really should be enough!
If you experience booting problems like missing modules / drivers then just boot from the genkernel section and fix the initrd building. You can look into the man page to tweak the command a bit (e.g. --add-drivers "xz dm_crypt" etc...).

Ok let's go on and finish the taks, we are going to tell now grub how to boot off correctly!

Option two: using better-initramfs

Piotr's better-initramfs is another approach that is tiny, nice and shiny and seems to become more and more a favourite among funtoo'ers. The biggest plus is that, once built it is kernel version independant.