Genkernel Quick Start Tutorial
Genkernel is a tool which help you to build a Linux kernel and deploy it along with a ramdisk image which contains all of the necessary modules to make the kernel being able to mount the different partitions of your harddrives in the VFS at the system startup.
Contents |
Concepts
Genkernel applied to the Debian sources
A good candidate to quickly start with Genkernel is the Debian kernel (sys-kernel/debian-sources) mainly because:
- Configuration files are available for the various platforms supported by the Derbian project
- The configuration makes an intensive use of putting features in modules
First step: emerging the rquired packages
The first step is to emerge:
- The Debian sources
- Genkernel itself
This is achieved with:
# emerge sys-kernel/debian-sources sys-kernel/genkernel
Once the Debian kernel sources are deployed, you should find a directory named linux-debian-version (e.g. linux-debian-2.6.32.30) under /usr/src. Update your the linux symlink to point on this directory:
# cd /usr/src # rm linux # ln -s linux-debian-2.6.32.30 linux
Second step: Grabbing a configuration file
If is now time to download the kernel configuration file. For this tutorial we will use a configuration file for AMD64 (several others architectures like MIPS or SPARC64 are available) as published by the Debian project, if you plan to use the Debian kernel you are advised to review it adjust it to your needs although it is tailored for a vast range of machines.
# cd linux # wget http://merkel.debian.org/~jurij/2.6.32-30/amd64/config-2.6.32-5-amd64.gz # gunzip config-2.6.32-5-amd64.gz
Third step: Building and installing the kernel
This is simply achieved by:
# genkernel --kernel-config=config-2.6.32-5-amd64 all
- --kernel-config: use the given name located in the kernel source tree (/usr/src/linux by default is taken unless overridden by --kerndir)
- all: rebuild the kernel image and the initramfs ramdisk.
Unless explicitly stated via --no-clean or no-mrproper, Genkernel will do a make mroprer in the kernel source tree, thus cleaning a previous build and removing the previous kernel configuration file in it.
If you use Genkernel to rebuild a Linux kernel on SPARC64, remember to either:
- Set Cross-compiler tool prefix in general setup
- Put --kernel-cross-compile=sparc64-unknown-linux-gnu- on the Genkernel command line