How to build a custom kernel
From FrugalWiki
This howto is based on the one crazy posted to the forums on Sun, 08 April 2007.
First, you don't need the kerne-source package because the build will create one for your custom kernel.
Next thing is you need a valid config first for the kernel you want to build, which doesn't need be the last stable one.
So :
Get the needed tools :
pacman -S pacman-tools
repoman update
Create your working dir like:
mkdir ~/kernel cd ~/kernel
Write your FrugalBuild in this dir
Stable kernel example ( like your one ):
pkgver=2.6.20 pkgrel=1 _F_kernel_name="-multimedia" _F_kernel_patches=(http://people.redhat.com/mingo/realtime-preempt/older/patch-2.6.20-rt8) Finclude kernel
This will build plain 2.6.20+rt-patch without the stable XX patches. If you know your_patches still works with the 'stable .XX' patches then add :
_F_kernel_stable=X
Where X is the STABLE release nr. Example :
_F_kernel_stable=6
This will build an 2.6.20.6+your_patches kernel
While you build an custom kernel you should build for your CPU. ( which you need set in your config ) Then add :
_F_kernel_dontsedarch=1
to FrugalBuild as well.
Something about patches. You can add more that one URL's or patches to _F_kernel_patches. Like:
_F_kernel_patches=(http://baz.org/foo.patch \ bar1.patch foo2.diff \ ftp://my.ftp.org/foo/my.patch)
NOTE: Patches without an URL need be in your work dir ( in this example ~/kernel )
Now you are done with the FrugalBuild but you are missing a config :)
If you already have one put it ~/kernel dir as well , if not just:
touch ~/kernel/config ( this will allow makepkg to run )
Run now :
makepkg -Hgdu
This will download kernel tarball+your_patches.
cd src
and unpack all source package ( kernel , compressed patches etc )
cd linux-*
and patch with your_patches.
If you already got a config do :
cp ../config .config && make oldconfig cp .config ~/kernel/config && cd ~/kernel && rm -rf src pkg
If you don't then:
make defconfig && make menuconfig
and make your config , save it and :
cp .config ~/kernel/config.i686 && cd ~/kernel && rm -rf src pkg
OK now we have everything done and could build the kernel.
run
makepkg -Hcu
and wait the kernel compiled :)
Once it is done you will have 3 *fpms in your ~/kernel dir.
As root ( or using sudo ) do:
pacman -U *.fpm
One last thing before rebooting :) You need to add a line for your kernel to /boot/grub/menu.lst
like :
title My New Cool RT Kernel - 2.6.20-multimedia-fw1 kernel (hd0,0)/boot/vmlinuz-2.6.20-multimedia-fw1 root=/dev/XXX ro vga=791
Save and you can reboot.
On problems just reboot with stock kernel and try to fix the issues you got , or ask in this forum or report bugs to the kernel_patchset Maintainer.
Now something about rc or git kernels which you could build too if you want of course.
If you want to build , say latest rt patchset ( which is AFAIK for 2.6.21-rc6 ) then just add this to your FrugalBuild :
_F_kernel_rc=X
Where X is the RC nr. Example :
_F_kernel_rc=6
This builds 2.6.21-rc6+your_patches.
NOTE: The kernel is still called 2.6.20.
This is because we use vanilla .20 + the rcX patch ( which will save you some 40MB download each time you build | rebuild that kernel )
If you want latest 'git' snapshot then add :
_F_kernel_git=X
Where X is the git snapshot nr. Example:
_F_kernel_git=1
NOTE: If you build 'git' kernels both _F_kernel_rc=X and _F_kernel_git=X *need* be there.
In this example you would build an 2.6.21-rc6-git1
I hope this helps you to build your custom kernel(s).
See 'man kernel.sh' for the full reference.