Tuesday, April 11, 2006

SLES9 kernel compile

I'm still getting to the bottom of why I/O on SLES 9 is so pathetic (future article with benchmarks on various HP server hardware). But I'm testing many kernel compiles and there wasn't a good recipe for SLES9 and vanilla 2.6 kernels. I've tested this with 2.6.16.1, 2.6.9, 2.6.12.6.

Sles 9 kernel build:

make sure you have the kernel source on the machine and gcc.

yast2 -i kernel-source gcc

then get the linux kernel and untar it (replace the kernel.org/foo.kernel stuff with a real path to a kernel):

wget http://kernel.org/foo.kernel.bz
tar -jxvf linux-2.6.6.1.tar.bz2

then move the kernel to /usr/src/

mv kernel-foo /usr/src/

remove old kernel build sim link:
rm /usr/src/linux

make new symlink to the new kernel:
ln -s /usr/src/kernel-foo /usr/src/linux

If you want to build a kernel with similar options to a SLES Kernel (building one with the old config), then you need to get and old .config file.
If you are running a plain SLES kernel:

zcat /proc/config.gz > /usr/src/linux/.config


or you can copy the .config file from a SLES kernel source:
cp /usr/src/linux-2.6.5-7.244/.config /usr/src/linux/.config

Now you have one more interactive part:
make oldconfig

That will ask questions about new options in the kernel that are not covered by the old .config only. You may be able to take all defaults.

I will break down the next steps with commentary, but the rest does not necessarily need intervention, so I usually stack them on a command line (see below):

Clean up configs:
make clean

Make a bootable linux image:
make bzImage

Compile loadable kernel modules (these are the same as drivers usually):
make modules

Install said drivers:
make modules_install

This makes a module dependency map and if it isn't done right you might not boot. The 2.6.16.1 will need to be replaced with the kernel version.
depmod -ae -F System.map 2.6.16.1

Install everything:
make install

So a line to do all of the post interactive stuff with a 2.6.12.6 kernel would look like:
make oldconfig && make clean && make bzImage && make modules && make modules_install && depmod -ae -F System.map 2.6.12.6 && make install

And then you might have to wait for a while. If you use grub as a bootloader, you shouldn't have to do anything else to run your new kernel except reboot. This whole process is so much easier than 2.0, 2.2 or 2.4 kernels. It still isn't as easy as apt-get upgrade kernel or yum update kernel or emerge or whatever, but such is the price you pay for SuSE.

No comments: