+ -

Pages

Saturday, May 18, 2013

Compile a new kernel in Linux

I did this on OpenSuSE 12.3

Its very easy, if you get everything right - just remember two things:

1. You won't get everything  right the first time
2. The 'make rpm' part takes hours, so plan your day accordingly

Very important: 
You need to get these packages installed successfully before you do anything.
1. GCC (On SuSE - do this: zypper install gcc)
2. ncurses (do this: zypper install ncurses)
3. rpm-build (again do this: zypper install rpm-build)

On fedora/redhat(if you're on RHN) replace zypper with 'yum'

-> Download the kernel from www.kernel.org
Make sure you get a 'not-too-old' kernel, as very old kernel have problems with the latest version of gcc and you'll end up with a lot o errors.

-> copy the kernel to /usr/src amd untar the kernel here.

-> link the kernel symbolically to /usr/src/linux by doing this:

ln -s linux-3.0.1 linux

once you've done this - cd /usr/src/linux

-> run this cmd: make mrproper

-> run this cmd: cp /boot/config-`uname -r` ./.config

-> run this cmd: make menuconfig

A menu will pop-up at this point. In this menu, scroll down to 'Load an alternate config file' and press enter.

Here, '.config' would be highlighted - select this option and save.

Back on the main menu, select General Setup and press enter. Look for 'append to kernel release' here and enter. You can type whatever yo want here and that will be added to the kernel name once it's built.

Save and exit.

-> run this cmd: make rpm
-> go have lunch and dinner with friends and come back

-> hopefully, you should have 2 rpm file now:

one under /usr/src/packages/SRPMS - with the name that you gave it
(mine is /usr/src/packages/SRPMS/kernel-3.0.1_1.1_veenux-1.src.rpm

and another under /usr/src/packages/RPMS/x86_64
(mine is /usr/src/packages/RPMS/x86_64/kernel-3.0.3_1.1_veenux-1.x86_64.rpm

Also, you'll find the headers rpm here, dont worry too much about that at this time.

-> now we create a ramdisk by:
# mkinitrd

Now, we need to load this kernel into the BootLoader and we're set!

Fire up Yast by # yast
->  go to Boot Loader
My SuSE is on Grub2 so all you have to do is go into Boot Loader options and change the selection of default kernel to the one you've built (it should be there in the dropdown) and save and exit.

Restart the machine and it'll load your kernel.



5 RakshaTec: Compile a new kernel in Linux I did this on OpenSuSE 12.3 Its very easy, if you get everything right - just remember two things: 1. You won't get everything  righ...

No comments:

Post a Comment

< >