banner ad

How To Compile A Kernel – The Mandriva Way Page 2

Each distribution has some specific tools to build a custom kernel from
the sources. This article is about compiling a kernel on Mandriva
systems. It describes how to build a custom kernel using the latest
unmodified kernel sources from www.kernel.org (vanilla kernel)
so that you are independent from the kernels supplied by your
distribution. It also shows how to patch the kernel sources if you need
features that are not in there.

5 Build The Kernel

To build the kernel, simply execute this command:

make rpm

Now be patient, the kernel compilation can take some hours, depending on your kernel configuration and your processor speed.

 

6 Install The New Kernel

After the successful kernel build, a src.rpm and an rpm package have been created. The src.rpm package can be found in the /usr/src/rpm/SRPMS/ directory, you can find out about its name by running

ls -l /usr/src/rpm/SRPMS/

On my system it was called kernel-2.6.18.3default-1.src.rpm.

The rpm package can be found in /usr/src/rpm/RPMS/i386/, /usr/src/rpm/RPMS/i586/, /usr/src/rpm/RPMS/i686/, /usr/src/rpm/RPMS/x86_64/, etc., depending on your architecture. On my system it was located in /usr/src/rpm/RPMS/i386/, and by running

ls -l /usr/src/rpm/RPMS/i386/

I found out that its name was kernel-2.6.18.3default-1.i386.rpm.

Now we can install our kernel rpm package like this:

cd /usr/src/rpm/RPMS/i386/
rpm -ivh kernel-2.6.18.3default-1.i386.rpm

You can now even transfer the kernel rpm package to other Mandriva systems and install it there exactly the same way, which means you don’t have to compile the kernel there again.

Next we create a ramdisk for our new kernel, because otherwise the system will most likely not boot our new kernel:

mkinitrd /boot/initrd-2.6.18.3-default.img 2.6.18.3-default

 

7 Configure The LILO Boot Loader

Now we must configure our LILO boot loader so that our new kernels gets booted when we restart the system.

Run

ls -l /boot

to find out about your new kernel (typically begins with vmlinuz, e.g. vmlinuz-2.6.18.3-default) and ramdisk (typically begins with initrd, e.g. initrd-2.6.18.3-default.img).

Then edit /etc/lilo.conf. Have a look at your existing (working) kernel stanzas there and take one of them as a sample for your new stanza and replace the kernel and ramdisk, then add the stanza above all other stanzas. Make sure you specify a unique name for that kernel in the label line (e.g. linux-2.6.18.3-default) and specify exactly the same name in the default line so that the kernel gets booted when you restart the system.

vi /etc/lilo.conf

For example, my lilo.conf looks like this before I add the new stanza:

# File generated by DrakX/drakboot
# WARNING: do not forget to run lilo after modifying this filedefault="linux"
boot=/dev/sda
map=/boot/map
keytable=/boot/us.klt
menu-scheme=wb:bw:wb:bw
compact
prompt
nowarn
timeout=100
message=/boot/message
image=/boot/vmlinuz label="linux" root=/dev/sda6 initrd=/boot/initrd.img append=" resume=/dev/sda5 splash=silent" vga=788
image=/boot/vmlinuz label="linux-nonfb" root=/dev/sda6 initrd=/boot/initrd.img append=" resume=/dev/sda5"
image=/boot/vmlinuz label="failsafe" root=/dev/sda6 initrd=/boot/initrd.img append=" failsafe resume=/dev/sda5"

and like this afterwards (keep in mind what I said about the label and default lines):

# File generated by DrakX/drakboot
# WARNING: do not forget to run lilo after modifying this filedefault="linux-2.6.18.3-default"
boot=/dev/sda
map=/boot/map
keytable=/boot/us.klt
menu-scheme=wb:bw:wb:bw
compact
prompt
nowarn
timeout=100
message=/boot/message
image=/boot/vmlinuz-2.6.18.3-default label="linux-2.6.18.3-default" root=/dev/sda6 initrd=/boot/initrd-2.6.18.3-default.img append=" resume=/dev/sda5 splash=silent" vga=788
image=/boot/vmlinuz label="linux" root=/dev/sda6 initrd=/boot/initrd.img append=" resume=/dev/sda5 splash=silent" vga=788
image=/boot/vmlinuz label="linux-nonfb" root=/dev/sda6 initrd=/boot/initrd.img append=" resume=/dev/sda5"
image=/boot/vmlinuz label="failsafe" root=/dev/sda6 initrd=/boot/initrd.img append=" failsafe resume=/dev/sda5"

Then run

lilo

Now reboot the system:

shutdown -r now

If everything goes well, it should come up with the new kernel. You can check if it’s really using your new kernel by running

uname -r

This should display something like

2.6.18.3-default

If the system doesn’t start, restart it, and when you come to the LILO boot loader menu, select your old kernel and start the system:

8 How To Compile A Kernel   The Mandriva Way Page 2

You can now try again to compile a working kernel. Don’t forget to remove the stanza of the not-working kernel from /etc/lilo.conf, and make sure you run

lilo

after modifying /etc/lilo.conf.

 

8 Links

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Filed Under: Kernel

Tags:

RSSComments (0)

Trackback URL

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.