nixCraft Linux Forum

nixCraft

Linux / UNIX 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

Linux answers from nixCraft.


Getting started tutorials So much to read, so little time! If that is your problem, we have solution. Read our FAQ and tutorials to help you cut through the clutter of information overload. Only members of "contributors" group can post new tutorials. Other members can just reply to thread.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 17-12-2006, 12:06 AM
B!n@ry's Avatar
Senior Member
User
 
Join Date: Dec 2006
Location: B!n@ry-z0ne
OS: Ojuba 3
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts
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
  #2 (permalink)  
Old 17-12-2006, 01:08 AM
rockdalinux's Avatar
Is that all you got?
User
 
Join Date: May 2005
Location: Planet Vegeta
OS: Redhat
Posts: 708
Thanks: 15
Thanked 19 Times in 18 Posts
Rep Power: 10
rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light
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.
What's wrong? I hope I am not making you uncomfortable...

Never send a boy to do a mans job.
Reply With Quote
  #3 (permalink)  
Old 17-12-2006, 01:25 AM
B!n@ry's Avatar
Senior Member
User
 
Join Date: Dec 2006
Location: B!n@ry-z0ne
OS: Ojuba 3
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts
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 17-12-2006, 01:40 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 244 Times in 183 Posts
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 Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #5 (permalink)  
Old 17-12-2006, 02:35 AM
sweta's Avatar
Contributors
User
 
Join Date: Feb 2005
Location: New Delhi
OS: Suse, RHEL, Vista
Posts: 199
Thanks: 12
Thanked 9 Times in 9 Posts
Rep Power: 7
sweta has a spectacular aura about sweta has a spectacular aura about
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
__________________
Reply With Quote
  #6 (permalink)  
Old 17-12-2006, 02:40 AM
B!n@ry's Avatar
Senior Member
User
 
Join Date: Dec 2006
Location: B!n@ry-z0ne
OS: Ojuba 3
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts
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 17-12-2006, 02:47 AM
chimu's Avatar
Contributors
User
 
Join Date: Mar 2005
OS: Ubuntu
Posts: 79
Thanks: 23
Thanked 4 Times in 3 Posts
Rep Power: 6
chimu is on a distinguished road
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 17-12-2006, 02:56 AM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
OS: Debian GNU/Linux
Posts: 506
Thanks: 0
Thanked 8 Times in 6 Posts
Rep Power: 7
monk has a spectacular aura about monk has a spectacular aura about
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 17-12-2006, 03:00 AM
B!n@ry's Avatar
Senior Member
User
 
Join Date: Dec 2006
Location: B!n@ry-z0ne
OS: Ojuba 3
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts
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 17-12-2006, 03:16 AM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
OS: Debian GNU/Linux
Posts: 506
Thanks: 0
Thanked 8 Times in 6 Posts
Rep Power: 7
monk has a spectacular aura about monk has a spectacular aura about
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


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 Off


Similar Threads

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


All times are GMT +5.5. The time now is 08:11 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

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 37 38