Kernel 3.0 Recompilation

View previous topic View next topic Go down

Kernel 3.0 Recompilation

Post  Panthymonium on Sat Oct 01, 2011 11:58 am

This is a step by step commented guide on how to compile a 3.0 kernel on Slackware 13.37. After reading some tutorials mainly on Alien BOB, Bob cares and Linux-france, I decided to write this note on my blog :

“Kernel Recompilation“. Man! what a dreadful name, there’s been a lot of hype surrounding the 3.0 kernel and as the saying goes “you’re virgin until you compile your first kernel” so all you trekkies out there know what to do now.

I’m using my favorite distro: Slackware 13.37

Why and when do we need to recompile a kernel ?

  • Add new features to the kernel (ie: Hardware support for a particular device)

  • Security updates and patches

  • upgrade to the latest version


I- Download the kernel source code

From www.kernel.org, it’s the HQ for the latest kernels and upstream fixes, but It’s down for the time being so we’re gonna make our way with a different mirror. I’ve picked up V 3.0.4 but you can choose whatever suits you.

/usr/src/ is the preferred location, however, you can untar and install wherever you want, for other distros like Red Hat, you can directly install in /usr/src/linux)

# cd /usr/src

#wget http://ftp.ntu.edu.tw/linux/kernel/v3.0/linux-3.0.4.tar.gz

#tar -xzvf linux-3.0.4.tar.gz


At this point, we’ve downloaded and uncompressed the source code, the next step is to remove the symbolic link to the old kernel and create a new one pointing to the kernel we’ve just downloaded:

#rm linux

#ln -s linux-3.0.4 linux


II- Configuration:


Since we don’t wanna configure the kernel from scratch we’re gonna copy the old configuration and then tweak it a bit to meet our requirements :

#cd linux

#cp /boot/config .config

#make oldconfig


Now, here’s the interesting part; configuration, this can be done in three ways:

  • make menuconfig (command line)

  • make xconfig (X Window based graphical environment)

  • make config (this is a yes/no based process and it’es very tedious, don’t choose unless you’ve lost a bet or something)


Tip: To help identify your hardware to enable the right features when configuring, you can run cat /proc/cpuinfo to retrieve information regarding your processor family, I’ll go with the core 2/newer xeon here . Use the libpci-based command lspci to display information regarding all PCI devices on the system including Network, Graphic Cards, etc.

For the purpose of this guide here, we’ll go on with xconfig, you can add some features like High-Memory support if you have more than 4GB of RAM, KVM support, SCSI device support, preemption model, special drivers etc

After you’re done, save and close the config window.

III- Installation:

If you’re using a 2.4 kernel you might need to build a list of dependencies with make dep, otherwise skip this to the next step:

# make bzImage


This will compile the kernel, and place it as a compressed file under arch/i386/boot then to compile the modules and install them:

#make modules

#make modules_install


This will copy the modules in /lib/modules/ .

Tip: The compilation process might take an important amount of time. Another compilation algorithm is faster then the one used with “make bzImage” but less effective (it might generate some errors if the kernel is too large), you can give it a try by running make zImage . Another technique is to use make -j<number> bzImage where “number” is the number of your processors, so in my case since i Have two processors I would process make -j2 bzImage , make -j2 modules, make -j2 modules_install

Next, move the recently compiled kernel to the boot directory ( it will be later on loaded into the memory at start up)

#cp arch/i386/boot/bzImage /boot/vmlinuz-3.0.4


If you’re recompiling the same kernel version then don’t forget to add -custom to the EXTRAVERSION (so it will look like this vmlinuz-3.0.4-custom) this way it won’t interfere with the old kernel.

Copy the System.map (this is an optional step for this file which is used by the kernel to map symbol names to their addresses in memory.)

#cp System.map /boot/System.map-3.0.4


Delete the link to the old System.map:

#rm /boot/System.map


Make a symbolic link for that specific kernel :

#ln -s /boot/System.map-3.0.4 /boot/System.map


At this point we’re done, still we should make an entry for that new kernel in lilo. Open the file /etc/lilo.conf

you’ll find the old entry, use it as template for the new one for example the old entry looked like this

image = /boot/vmlinuz

root = /dev/sda2

label = Linux

read-only


The new one would look like this

image = /boot/vmlinuz-3.0.4

root = /dev/sda2

label = CustomKernel

read-only


Save and close, run:

#lilo


to update the bootloader and that’s it, now reboot into your new kernel and check its version with uname -r. That’s it!

Tip: it’s always safe to keep an entry for the old kernel until you’re sure that the new one is working fine, this way, if anything goes wrong, you can always use the old kernel for recovery.

Source


Last edited by Panthymonium on Sun Oct 02, 2011 12:07 pm; edited 2 times in total (Reason for editing : Font size, general formatting)

Panthymonium

Posts: 13
Join date: 2011-03-12
Age: 26
Location: Tunisia

http://cloudweave.wordpress.com/

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum