LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-16-2003, 11:54 PM   #1
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 60
Newbie Guide To Compiling A Kernel!


first and foremost, THIS may pertain to you so read that first and then you can proceed
and here is a similiar site

www.kernel.org
**"Go get the kernel source"**

cd /usr/src
**"Change Directory To /usr/src"**

ls -alc
**"check for symlink (ex. /usr/src/linux->/usr/src/linux-2.4.18)"**
**"also note since its being ask recently, that if there is no symlink"**
**"then move on to the untarring of the kernel"**

file linux
**"double check with this command (output ex.) linux: symbolic link to linux-2.4.18-14"**

rm linux
**"remove symlink"**

tar -zxvf linux-x.x.x.tar.gz
**"unpack the tarball (new kernel)"**

ln -s /usr/src/linux-x.x.x /usr/src/linux
**"make a new link to the new kernel"**

cd linux
**"type this to change to the directory"**

----------------------------
Now Comes The Fun Part~!
----------------------------
make mrproper
**"this removes the current .config and other files"**

cp /usr/src/linux-2.4.x/.config /usr/src/linux
***this is if you want to use your old config***

<-->Your Choice<-->
make config
**"basic config from terminal"**
make menuconfig
**"for ncurses GUI in the terminal"**
make xconfig
**"for X-based GUI with modular explanations"** (QT Based)
make gconfig
**"same as above, but for 2.6.x kernel only"** (GTK Based, and might be still buggy)

/**********
Note:
Don't forget to add module support and kernel support for future hardware.
Do not compile your harddrive and filesystem type as a module.
The configure program enables you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. Most options are about specifying whether you want a feature[*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. You can also turn off module support altogether from Loadable module support -->. The kernel configuration is one LINUX program that offers lots of help--select < Help > on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can be also worth reading.
When your done the config click exit and save current configuration. Your file is now known as .config .
**********/
SKIP THE FOLLOWING IF DOING A 2.6.x KERNEL
make dep
**"ensures dependancies such as include files are in place"**

(vi, pico, emacs) Makefile
**"Want A Unique Kernel Name? Edit /usr/src/linux/Makefile and change EXTRAVERSION"

make clean
**"to clean your sources for they compile correctly"**

START HERE IF COMPILING A 2.6.x KERNEL

make bzImage
**"to make the kernel image (compile and creates compressed image of kernel)"**

make modules
**"compile your selected modules"**

make modules_install
**"to install newly compile modules (installs to /lib/modules/linux.x.x.x)"**


--------------------------------------------
Now Its Time To Install Your New Kernel~!
--------------------------------------------

Remove the following links:
rm -rf /boot/System.map
rm -rf /boot/vmlinuz

Then copy the newly created kernel and system.map to /boot
cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-x.x.x
cp /usr/src/linux/System.map /boot/System.map-x.x.x

Make the new links:
ln -s /boot/vmlinuz-x.x.x /boot/vmlinuz
ln -s /boot/System.map-x.x.x /boot/System.map

<-> NOTE: <->
Before doing the next step, read this [1] and this [2] about the initrd.img and see if you even need to do this step ... there is alot of posts
about this step, so i am adding this section ...
<-> END NOTE <->

Next remove existing initrd.img file:
rm -rf /boot/initrd.x.x.x.img

..And create the new one:
/sbin/mkinitrd /boot/initrd-x.x.x.img x.x.x
(Note: )
The last set of x.x.x is the eqivalent to your new kernel version and it looks to /lib/modules for that version.

--------------------------------------------------------------------
Use The Steps That Pertain To You
If You Use Grub Then Edit grub.conf
If You Use Lilo Then Edit lilo.conf
--------------------------------------------------------------------
remember to leave the entry to your old kernel image just in case,
so modify what is in the config originally to point to the old image
and make a new entry for you new image you just made ....

--------------------------------------------------------------------

<-> And Finally Edit Your /etc/grub.conf file <->
<-> Note some distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for <->

title New Kernel
kernel /vmlinuz-x.x.x ro root=LABEL=/
initrd /initrd-x.x.x.img
(Note: )
look at the previous parameters in the grub.conf file and note what "root=" and use what is existing.

Exit and Save grub.conf
type "/sbin/grub-install"

AND REBOOT!!!

<-> And Finally Edit Your /etc/lilo.conf file <->
image = /boot/vmlinuz-x.x.x
label = New Kernel
root = /dev/hdx
read-only

(Note: )
look at the previous parameters in the lilo.conf file and note what "root =" and use what is existing.

Exit and Save lilo.conf
type "/sbin/lilo"

AND REBOOT!!!



/******EDIT*******
as requested there was wanting the instructions on how to apply patches to your kernel.
****END EDIT*****/

read this or look below ..

This step comes after untaring your kernel source.
When you download the patch place it in the folder that you untarred you new kernel.
Then type:
patch -E -p1 < sound_patch
Purely an example and you would type whatever the file name is in replace of sound_patch.


As of having alternative boot options, well this is no problem.. The stuff above that i tell you to add to your lilo or grub file above could just append the file, and just add ".old" to the title of your oringinal kernel name for you will know the difference. and whether its grub or lilo add "read-only", to the end of the oringinal entries in the lilo.conf, or grub.conf file.

Last edited by DrOzz; 05-25-2004 at 04:27 PM.
 
Old 07-16-2003, 11:57 PM   #2
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Original Poster
Rep: Reputation: 60
so why did i do this?

well i figured i would write a completely new guide with detailed explanations on whats going on, and these steps can address a larger crowd then most guides do, with how they are set up..
so if anyone notices anything wrong or feels there is something i missed, then i'll be glady to add to it or fix it...

Last edited by DrOzz; 05-25-2004 at 04:30 PM.
 
Old 07-17-2003, 05:01 AM   #3
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
Thanks a lot, that's very helpful -- when I'm a grown up Linux person I will try that ...

I think most people are a little nervous, when you ask them to delete their kernel. Or at least I would be.

Why not create the new kernel as an alternative (and show the changes in the symlinks, GRUB / LILO), so one has (two or more) different boot options.

Oh, yes, what about handling patches? <- more work for you

Last edited by JZL240I-U; 07-17-2003 at 06:34 AM.
 
Old 07-17-2003, 06:30 AM   #4
laxi
Member
 
Registered: Jun 2003
Distribution: Linux
Posts: 48

Rep: Reputation: 15
thank very much ,Drozz~!
I compiled the new kernel ,but there is some puzzle.
I compiled the APM in the kernel ,but why i still cant shut the the computer with poweroff ?(it cant shut down with power)
if I want to put my modem modules in the kernel ,what should i do?
help me please~thanx
 
Old 07-17-2003, 09:54 AM   #5
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Original Poster
Rep: Reputation: 60
as of the APM laxi i am not too sure about that, hopefully someone can help you with that, i can't see why its not working if you compiled it into the kernel, unless you compiled it as a module and the module is not loaded...so i guess maybe you could try modprobe apm, and then try shutting down to see if that was the case.
and the modem, maybe this applies to the patch section i described above.
 
Old 07-17-2003, 02:11 PM   #6
Pcghost
Senior Member
 
Registered: Feb 2003
Location: The Arctic
Distribution: Fedora, Debian, OpenSuSE and Android
Posts: 1,820

Rep: Reputation: 46
Hey laxi, are you sure your laptop isn't using ACPI instead of APM? A lot of laptops are using ACPI these days..
 
Old 07-17-2003, 11:59 PM   #7
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Original Poster
Rep: Reputation: 60
also another alternative thats there if you want to use it is something like this :
cp -R /boot /boot2
mv /usr/src/linux/System.map /boot2
mv /usr/src/linux/arch/i386/boot/bzImage /boot2/vmlinuz
mv /usr/src/linux/vmlinux /boot2

before you do any of the steps mentioned above. thats a very brief and quick explanation and i may have missed something but i am sure you'll get the idea if you want to setup your old kernel like so...also making changes to your .conf files of course, etc,etc....
 
Old 07-18-2003, 09:49 AM   #8
raylpc
Member
 
Registered: Jun 2003
Location: Canada
Distribution: Red Hat 9
Posts: 94

Rep: Reputation: 15
What's the use of System.map and initrd-x.x.x.img? My system is working fine without them?

Thanks
 
Old 07-18-2003, 11:12 AM   #9
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Original Poster
Rep: Reputation: 60
Quote:
There are 2 files that are used as a symbol table:
/proc/ksyms
System.map
Every time you compile a new kernel, the addresses of various symbol names are bound to change.

/proc/ksyms is a "proc file" and is created on the fly when a kernel boots up. Actually, it's not really a file; it's simply a representation of kernel data which is given the illusion of being a disk file. Therefore, it will always be correct for the kernel that is currently running..
However, System.map is an actual file on your filesystem. When you compile a new kernel, your old System.map has wrong symbol information. A new System.map is generated with each kernel compile and you need to replace the old copy with your new copy.
Quote:
The initrd is the "initial ramdisk". It is enough files stored in a ramdisk to store needed drivers . You need the drivers so that the kernel can mount / and kick off init.
You can avoid this file 'initrd.img' and eliminate the need of 'initrd.img', if you build your scsi drivers right into the kernel, instead of into modules.
 
Old 07-18-2003, 11:46 AM   #10
raylpc
Member
 
Registered: Jun 2003
Location: Canada
Distribution: Red Hat 9
Posts: 94

Rep: Reputation: 15
Quote:
The initrd is the "initial ramdisk". It is enough files stored in a ramdisk to store needed drivers . You need the drivers so that the kernel can mount / and kick off init.
You can avoid this file 'initrd.img' and eliminate the need of 'initrd.img', if you build your scsi drivers right into the kernel, instead of into modules.
Hm.. I built my scsi drivers as modules, and deleted the initrd.img from the grub.conf, but my system seems to work fine. How come?

PS. there's a file called module-info, what's it? how can I generate it when compiling a new kernel? I'm using Red Hat 9.

Thanks

Last edited by raylpc; 07-18-2003 at 11:50 AM.
 
Old 07-18-2003, 03:08 PM   #11
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Original Poster
Rep: Reputation: 60
well i am not quite sure how your system is set up and why it does / doesn't work how it does...what distro are you using, i only wrote this article to be used on alot of distros not all distros....
as of the module-info file it is a link to module-info-{kernel-version}
Contains information about all available modules (at least those
included in the default kernel config.)
might be used by kudzu to determine default parameters for modules when it creates entries in /etc/modules.conf (guessing here)
thats all i can gather, maybe someone else has some better answers for you specific question.
 
Old 07-18-2003, 11:08 PM   #12
laxi
Member
 
Registered: Jun 2003
Distribution: Linux
Posts: 48

Rep: Reputation: 15
thank you Drozz,i use the old kernel ,and when i modprobe apm
the power can shut down with the command poweroff,but i use the kernel compiled by myself (i add the apm into kernel,when i compiled it),it cant shutdown ,just display Power Down in the end.
is there something else i should do when i use the new kernel?
thanks everbody~
 
Old 07-18-2003, 11:14 PM   #13
laxi
Member
 
Registered: Jun 2003
Distribution: Linux
Posts: 48

Rep: Reputation: 15
thanks Pcghost,but my computer is not a laptop.the ACPI is a power manage module,all right?can it use in my computer ?
 
Old 07-18-2003, 11:31 PM   #14
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Original Poster
Rep: Reputation: 60
did you compile it as a module ? if so is it being started, if not, did you try modprobe apm with the new kernel? you may have meant to answer these things, but i don't seem to see the answers to these questions in what you just said.
 
Old 07-19-2003, 12:42 AM   #15
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
Talking Why recreate the wheel

Try this link instead

http://www.justlinux.com/nhf/Compili...mpilation.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I'm interested in compiling a 2.6.x kernel, is this is a decent guide? Erik_the_Red Linux - Newbie 7 08-14-2005 06:03 AM
Kernel compiling guide for newbies... DaOne Slackware 127 04-17-2005 04:20 AM
Acid Guide to compiling Kernel 2.6.10 on Slack 10.1 acidjuice Slackware 54 03-11-2005 05:16 PM
Quick newbie guide to rebuild kernel in FC3 borgware Fedora 0 12-29-2004 01:38 PM
: Kernel compiling guide for newbies Question Anibal Slackware 6 08-01-2003 07:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration