nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

mini HOWTO - Linux Kernel Compilation

This is a discussion on mini HOWTO - Linux Kernel Compilation within the Getting started tutorials forums, part of the Linux Getting Started category; Hello All , I told you I shall be back with a new idea Today this article came to my ...


Go Back   nixCraft Linux Forum > Linux Getting Started > Getting started tutorials

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 12-17-2006, 01:06 AM
Senior Member
User
 
Join Date: Dec 2006
Location: /B!n@ry
My distro: openSuSE 10.2
Posts: 127
Rep Power: 0
B!n@ry
Send a message via MSN to B!n@ry
Default mini HOWTO - Linux Kernel Compilation

Hello All,

I told you I shall be back with a new idea Today this article came to my mind to write about because when ever I go to a forum I see the same question: How can I compile a Kernel ?

Really this questions is asked by lots of people not just newbie's but even intermediate users. So I decided to write this short article to help out.

Important Note:
Do not run a command as root until I say so.

1st: you download the latest Kernel version from here: http://www.kernel.org/

2nd: Move the file you downloaded into a directory change to it and if the kernel is downloaded in a gz file type ? you extract it like this:
Code:
tar xvfz kernel-package.gz
if its a bz2 type you extract it like this:
Code:
tar xvfj kernel-package.bz2
3rd: Enter the directory you just extracted and run any of the following kernel configuration types:
1. make config
2. make oldconfig
3. make menuconfig
4. make gconfig
5. make xconfig
Note:- Not all of them exist by default on a Linux System, you need to install them.

the "make config" is a Q&A configurator. "make oldconfig" is used when you have a pre-config file and want to reuse it in compiling the new Kernel. "make menuconfig" is just like the netconfig that runs under CLI and you choose the needed options by marking them with a correct sign. "make gconfig" is a configurator running under GTK+. "make xconfig" is also a configurator run under QT.

4th: Now run
Code:
make
inside the directory of the kernel. This shall build the bzImage.

Important Note:
Now continue to run the commands as root.

5th: Install the needed modules for the kernel. Run this:
Code:
make modules_install
6th: Install the new Kernel, by doing the following:
Code:
cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.0
Code:
cp System.map /boot/System.map-2.6.0
7th: All you have to do now is edit the boot loader used, here I use GRUB. Add the following lines to the end of the file:
Code:
title SUSE Linux 10.1 using Kernel vmlinuz-2.6.0
    root (hd0,0)
    kernel /vmlinuz root=/dev/hda3 vga=0x317 splash=silent showopts
    initrd /initrd
Finally: Reboot your machine you shall have a new running Kernel.

I hope you like this mini HOWTO - Linux Kernel Compilation

Regards 2 all,
B!n@ry
__________________
LivE Free 0r DiE
L!nux rul3z aLL
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-17-2006, 02:08 AM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 581
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

Good work.

LOL first i could not recognize you B!n@ry; did you changed your name or what?

ALso don't forget to include your drivers. If you are using RHEL and if u r lazy use up2date command to upgrade binary kernel:
Code:
up2date -uf
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote
  #3 (permalink)  
Old 12-17-2006, 02:25 AM
Senior Member
User
 
Join Date: Dec 2006
Location: /B!n@ry
My distro: openSuSE 10.2
Posts: 127
Rep Power: 0
B!n@ry
Send a message via MSN to B!n@ry
Default

Quote:
Originally Posted by rockdalinux
Good work.

LOL first i could not recognize you B!n@ry; did you changed your name or what?

ALso don't forget to include your drivers. If you are using RHEL and if u r lazy use up2date command to upgrade binary kernel:
Code:
up2date -uf
Yep, I asked nixcraft and he did it for me, because this is my real nickname on the net

What do you mean about the drivers ? if you mean modules I have added them or do you mean somthing else ?

Also for FC# users using yum do the following:
Code:
yum -y install kernel
for users using smart:
Code:
smart install kernel

waiting for more useful addons :P
__________________
LivE Free 0r DiE
L!nux rul3z aLL
Reply With Quote
  #4 (permalink)  
Old 12-17-2006, 02:40 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,060
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

I am not at all a fan of an RPM based Linux distro but my work alway force me to use RHEL

Debain Linux
Code:
apt-get install kernel-image-version
Ubuntu Linux
Code:
sudo apt-get install kernel-image-version
To find out kernel version
Code:
apt-cache search kernel-image
Quote:
What do you mean about the drivers ? if you mean modules I have added them or do you mean somthing else ?
Device drivers is MS-Windows term form H/w driver
Modules is UNIX/Linux term form H/w driver so both of you are right. Rocky use modules word heh

If you are using RAID card make sure you download driver from card manufacturer ftp/www server. Otherwise you will see famous kernel panic message.

Also don't forget

Exploring Linux kernel => http://blogs.cyberciti.biz/hm/index....-linux-kernel/

Howto: build Linux kernel module against installed kernel w/o full kernel source tree => http://www.cyberciti.biz/tips/build-...urce-tree.html
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #5 (permalink)  
Old 12-17-2006, 03:35 AM
sweta's Avatar
Contributors
User
 
Join Date: Feb 2005
Location: New Delhi
My distro: Suse, RHEL, Vista
Posts: 154
Rep Power: 4
sweta will become famous soon enough
Default

To use make menuconfig you need curses lib aka libncurses. For remote server I always use make menuconfig X is not an option and other methods are just boring
__________________
Friends - v-nessa - missyAdmin - LinuxChix
Reply With Quote
  #6 (permalink)  
Old 12-17-2006, 03:40 AM
Senior Member
User
 
Join Date: Dec 2006
Location: /B!n@ry
My distro: openSuSE 10.2
Posts: 127
Rep Power: 0
B!n@ry
Send a message via MSN to B!n@ry
Default

thanx nixcraft for the addon, u made me remember to put this command:
Code:
uname -r
to know the running kernel version

By the way nixcraft I really think Debian is hard to run and operate maybe I am wrong and maybe not
__________________
LivE Free 0r DiE
L!nux rul3z aLL
Reply With Quote
  #7 (permalink)  
Old 12-17-2006, 03:47 AM
chimu's Avatar
Contributors
User
 
Join Date: Mar 2005
My distro: Ubuntu
Posts: 33
Rep Power: 0
chimu is an unknown quantity at this point
Default

Quote:
Originally Posted by B!n@ry
thanx nixcraft for the addon, u made me remember to put this command:
Code:
uname -r
to know the running kernel version

By the way nixcraft I really think Debian is hard to run and operate maybe I am wrong and maybe not
Debain gud for servers & FC/Ubuntu for gud for desktop

Real man love to use Gentoo
Reply With Quote
  #8 (permalink)  
Old 12-17-2006, 03:56 AM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

Quote:
Originally Posted by chimu
Real man love to use Gentoo
Naa real men assemble their own Linux system using Linux From Scratch www.linuxfromscratch.org

Quote:
8th: Re-install the boot loader GRUB using the following command: Code:
grub-install
Why to run grub-install? This is wong. grub-install only needed when you would like to play with MBR and not when updating kernel. Please update your post and remove grub-install
Reply With Quote
  #9 (permalink)  
Old 12-17-2006, 04:00 AM
Senior Member
User
 
Join Date: Dec 2006
Location: /B!n@ry
My distro: openSuSE 10.2
Posts: 127
Rep Power: 0
B!n@ry
Send a message via MSN to B!n@ry
Default

Quote:
Originally Posted by monk
Why to run grub-install? This is wong. grub-install only needed when you would like to play with MBR and not when updating kernel. Please update your post and remove grub-install
Hello monk,
well I only do this to insure that nothing goes wrong, speacilly when some cannot read from where to load the modules needed at boot time. All the rest you are precisly write about it or I am wrong and unable to explain for you.
__________________
LivE Free 0r DiE
L!nux rul3z aLL
Reply With Quote
  #10 (permalink)  
Old 12-17-2006, 04:16 AM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

grub-install - use to install GRUB boot loader on your hard disk. There is no relationship exists between GRUB and kernel upgrade. If you run grub-install it will just reinstall GRUB.

In olden days you need to run lilo command after kernel upgrade. First you will edit /etc/lilo.conf with something as follows:
Code:
image=/boot/vmlinuz
	label=linux
	initrd=/boot/initrd-version.img
	read-only
	root=/dev/hda2
Once you are sure that /etc/lilo.conf is properly configured for new kernel, run to load new changes and kernel:
Code:
lilo -v -v
However grub can read grub.conf file on fly no need to write MBR again.

This is one big difference between GRUB and LILO: With LILO, every time you rebuild your kernel, you will need to reinstall the boot loader (run sbin/lilo). So, there can be less of a maintenance issue with GRUB. Also you'll need to execute lilo again after any changes are made in /etc/lilo.conf.

Rests of your commands are correct
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Mini How to :: How to configure ssh keys on Linux Ashish Pathak Getting started tutorials 3 08-31-2008 03:18 PM
Linux kernel deleted from /boot - how do I resinstall the kernel vaibhav.kanchan Getting started tutorials 2 03-25-2008 01:31 AM
Display Linux kernel information sweta Getting started tutorials 0 07-27-2007 08:00 AM
Smart mini HowTo B!n@ry Getting started tutorials 4 12-17-2006 04:23 AM
Is Linux kernel is monolithic or modular kernel? chiku Linux software 2 06-02-2005 04:40 PM


All times are GMT +5.5. The time now is 03:59 AM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36