LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Kernel compiling guide for newbies... (https://www.linuxquestions.org/questions/slackware-14/kernel-compiling-guide-for-newbies-49035/)

DaOne 03-09-2003 09:36 PM

Kernel compiling guide for newbies...
 
I know how frustrating it can be for slack noobs...everyone tells you that slack is too hard for a newbie and then when you're faced with your first kernel compile...fear rolls in. Relax...slack isn't hard...it just makes you learn quicker. Compiling a custom kernel isn't hard...it just requires that you pay attention and follow the proper procedures. Once you've successfully installed slackware, then customized your kernel, you are well on your way to unleashing the raw power of linux...under the best (IMO) distro ever made.

Now to the compiling part...

First, we need to edit lilo.conf. Pick your favorite editor...one that is easy for newbies (and I still use this from time to time) is pico.

pico /etc/lilo.conf

Add this to your config...you can just copy what is there and add the .old stuff.

image = /boot/vmlinuz.old

root = /dev/hda1

label = slack.old

read-only


Note: Replace /dev/hda1 with the correct location of your root partition.

Now we need to edit the Makefile to make sure your new kernel is copied to the appropriate directory.

If you are using 8.1 or later, open /usr/src/linux/Makefile in a text editor, scroll to line 74 and
uncomment the the line #export INSTALL_PATH=/boot.
For 8.0 you must leave this line commented.

So...cd /usr/src/linux

pico Makefile

scroll to line 74 and
uncomment the the line #export INSTALL_PATH=/boot.
For 8.0 you must leave this line commented.


Now for the fun :)

make menuconfig (make your changes here...when done, save your new configuration)
make dep (sets all the kernel dependencies)
make clean (removes un-needed files)
make bzImage (builds the kernel)
make
make install (installs, moves and renames all the needed files and updates lilo)
make modules (builds all the kernel modules)
make modules_install (installs the modules)

Note: The 'make install' command is the one that most don't use but it works fine in slackware as long as you have prepared lilo.conf and edited Makefile according to the instructions above.

Now you can reboot using your new kernel!!!

If things did not go completely according to plan you can boot your old (working)
kernel by selecting slack.old at the lilo screen.

This is my bible when it comes to recompiling my kernel, and it has never, ever failed.
Enjoy your new kernel!

Note: All references from http://p-two.net
written by one of our own Moderators!

Yorky 03-10-2003 01:54 AM

Good post - I have saved it and will use it when I can gather the strength to try compile my 1st kernel :=))

SLaCk_KiD 03-10-2003 02:13 PM

DaOne helped me get my first compile right, he was understanding of my fustration
and very patient with me. I dont think that i have anything to complain
about at all. Everyone here in the slack forum is always willing to help out
That is what I like about Slack, the people who use it are knowledgable
and always seem to lend a hand when it is needed. Thanks to all of you
who try to help us n00b's out!! hopefully one day when I know
the answers to questions that are asked, i can be as helpful as you guys....thnaks again!

DaOne 03-13-2003 06:19 PM

Glad at least one person got something good out of this. Just a note...all of this still still works through rc2...:)

figadiablo 03-14-2003 06:21 AM

I have compiled kernerls sucesfully before, but my questions is: If I just wanna improve from the current configuration or add something that I left out, some module; do I type make oldconfig or something so that when I do the menuconfig I see my current configuration? Or do I have to do everything from scratch and hope that I dont leave something else out? Am I complicating things out?

Thanks,
Figa

DaOne 03-14-2003 10:52 AM

When you type make menuconfig, your current configuration will be used. So no, you do not need to start over each time.

trn 03-14-2003 07:21 PM

a tip also, after make menuconfig you can use the line "make dep && make clean bzImage modules modules_install" then go get a bite to eat or whatever and when you come back everything is all compiled and ready to go. (and yes i stole this from the gentoo install guide.. just a handy tip.)

DaOne 03-14-2003 07:33 PM

Quote:

"make dep && make clean bzImage modules modules_install"
This can be done if you plan to manually copy bzImage to /boot/vmlinuz, and then update lilo. Otherwise, the new kernel wouldn't be copied to the proper location, which is what make install does for you...it will copy the kernel to the appropriate location, and updates lilo.

figadiablo 03-14-2003 09:38 PM

Ok, maybe I'm a little dumb today, but I wan't to make sure that I get this. For example if Im using the 2.4.18, which I've already recompiled for my likings, and then go and download 2.4.20. When I type make menuconfig, does that means that the computer is going to scan the settings that Im already using and they will appear in the new kernel Im compiling? In other words will I see my curent config with the 2.4.20?

Before I forget, thaks for the earlier response,
Figa

DaOne 03-14-2003 10:06 PM

What you'll need to do in that case is copy your current config to the new kernel source tree...here is how I like to do this.

Once the new kernel source is in place, cd to that directory...

cd /usr/src/linux-2.4.20
make mrproper

Then copy your 2.4.18 config...

cp /usr/src/linux-2.4.18/.config /usr/src/linux-2.4.20/.config

Then you can run make menuconfig...your current configuration will be in place. There will likely be some new features in the new kernel, so you'll want to make sure you go through the configuration menu and add/remove as necessary. Once you are satisfied, you can save your changes, and continue on to make dep and so on.

figadiablo 03-15-2003 02:06 PM

DaOne,
Thanks for the reply. Something new that I just learn.

Figa

Aussie 03-15-2003 07:02 PM

If you plan to use your previous .config you can do "make oldconfig" and it will only prompt for new kernel options.

DaOne 03-15-2003 07:42 PM

Quote:

If you plan to use your previous .config you can do "make oldconfig" and it will only prompt for new kernel options.
Thanks Aussie...I forgot about that one :)

figadiablo 03-15-2003 08:41 PM

cool yeah!! I knew there was a make oldconfig somewhere. Thanks for the tips guys!

Figa

Astro 03-19-2003 01:21 PM

I find that the commands make modules and make modules_install tends to mess up my kernel QUITE a bit.... i use make menuconfig; make dep; make clean; make bzImage; cp arch/i386/bzImage /boot then edit lilo accordingly...if I do the make modules and make install and make modules_install it doesnt always work, in fact it never does even if I have modules to install... not sure why at all..so I use the method I described above and it works every time.

narusegawa 03-20-2003 05:01 AM

On Slackware 8.1 there is both /usr/src/linux/ and /usr/src/linux-2.4.18/

Which of these two is the one to edit? Both directories contents look the same to me [New to linux]


All I want to do is add NTSF Read/Write to my kernel, leaving all else as is. Just adding support for NTSF is all I want to do. Thanks

Aussie 03-20-2003 05:20 AM

Quote:

Originally posted by narusegawa
On Slackware 8.1 there is both /usr/src/linux/ and /usr/src/linux-2.4.18/

Which of these two is the one to edit? Both directories contents look the same to me [New to linux]
/usr/src/linux is a symbolic link to /usr/src/linux-2.x.xx
Code:

bern@grendel bern$ ll /usr/src/linux
lrwxrwxrwx    1 root    root          12 Mar 20 18:42 /usr/src/linux -> linux-2.4.20

Quote:

Originally posted by narusegawa
All I want to do is add NTSF Read/Write to my kernel, leaving all else as is. Just adding support for NTSF is all I want to do. Thanks
You don't need to recompile in slackware if you want ntfs read-only support, and writing to ntfs is likely to corrupt your data. Do "modprobe ntfs" to load the read-only module, edit /etc/rc.d/rc.modules to load it at boot. If you need to transfer data between linux and windows on ntfs then the best option is to create a small fat32 partition.

narusegawa 03-20-2003 05:25 AM

I need NTSF Write, I need to access(R/W) the same files in both Windows and Linux, however the files are fixed in C:/Documents and Settings/ and there is no options to change where I can put these files. And I don't want to have to copy the files to a different partition everytime I just want to boot into Linux. And then back again once I boot into windows again.

The files are only ASCII files, less than 50kb each too. I'm not writing large binary files. Just simple plain text ASCII files readable by Vi etc...


-----

If there was a way to do a "Symbolic Link" in windows then that would make things incredibly easier. I'd simply create a small FAT32 partition somewhere with sym links from both O/S's to it.

Aussie 03-20-2003 05:53 AM

What the files are is besides the point, you can enable ntfs write support in linux but, and it's a _big_ but, it's buggy and can trash your data.
Even the kernel config has a warning about enabling ntfs write support.

narusegawa 03-20-2003 05:57 AM

Ok, thanks for the advice. I think I'll just enable ntsf-read then and find a way to move files within windows upon shutdown.

Hopefully ntsf-write might be better in the future eh.

undershepherd 03-21-2003 08:03 AM

Could someone explain to a newbie who has never compiled a kernel, what is this all about? The talk of compiling with individual settings, etc. has me confused. I run Mandrake 9, had a go at Red Hat 8, but for some reason it will not install, but MD 9 will. ANyway, I also had the enormously fun time of gettting the NVIDIA drivers installed. I found on another forum step by step for newbies and when I did that, wow, the NVIDIA splash screen appeared, I screamed and whooped, sending my wife into orbit next to me.
Thank you to all who take the time to help out here. I am so much happier with Linux, just still a little behind on the learning curve, such as still having problems trying to install programs that need dependencies, then those need dependencies, etc. But when it works, what joy!!

Aussie 03-21-2003 09:08 AM

When you compile a custom kernel you can build it with support for the hardware it runs on and leave out anything that you don't need, this gives you a small kernel, and a small kernel is a fast kernel.

Stalkz 03-24-2003 09:09 PM

Quote:

Originally posted by SLaCk_KiD
DaOne helped me get my first compile right, he was understanding of my fustration
and very patient with me. I dont think that i have anything to complain
about at all. Everyone here in the slack forum is always willing to help out
That is what I like about Slack, the people who use it are knowledgable
and always seem to lend a hand when it is needed. Thanks to all of you
who try to help us n00b's out!! hopefully one day when I know
the answers to questions that are asked, i can be as helpful as you guys....thnaks again!


Word, this is a pretty sweet forum from what I've read so far, everyone's nice as hell...

narusegawa 03-27-2003 04:23 AM

I'm having problems with the boot kernels on the Slackware 9 CD. No matter which one I choose I get a problem immediately before I'm allowed to type 'root' (I can't because the error disable all my usb connections)

Is there a way to compile a custom kernel to boot the install from?

Aussie 03-27-2003 05:05 AM

Slackware 8.1 had a kernel with usb mouse and keyboard support called usb.i, but this is in the 9.0 release notes,
Quote:

Support for USB keyboards is now integrated into the installer. If USB
device detection causes problems (it shouldn't), it may be skipped by
passing the kernel a "nousb" flag at boot.
So try doing "bare.i nousb" at the kernel prompt.

narusegawa 03-27-2003 05:20 AM

If I do that, then what would I choose when it asks me what kernel to install?

And how would I then go about enabling usb once I've installed? Would it just be a simple rc.modules edit or would I need to recompile the kernel in some fashion? Or does passing nousb to the kernel not disable the usb stuff but puts it as modules instead. So that they can be loaded with rc.modules?

Thanks

Aussie 03-27-2003 06:15 AM

Quote:

Originally posted by narusegawa
If I do that, then what would I choose when it asks me what kernel to install?
bare.i

Quote:

Originally posted by narusegawa
And how would I then go about enabling usb once I've installed? Would it just be a simple rc.modules edit or would I need to recompile the kernel in some fashion?
Hotplug is doing a sterling job with my pci and usb devices, there is a comment about it in the release notes as well, PV calls it "a major, major step forward", I was surprised when I saw the emu10k1 module load during my post install boot.

Quote:

Originally posted by narusegawa
Or does passing nousb to the kernel not disable the usb stuff but puts it as modules instead. So that they can be loaded with rc.modules?

Thanks

I don't know, give it a try and tell us what happens..and error messages are always welcome :-)

wr3ck3d 03-28-2003 08:27 PM

Ok, I have a fresh install of slackware 9. What arch is this kernel compiled for??

Quote:

When you compile a custom kernel you can build it with support for the hardware it runs on and leave out anything that you don't need, this gives you a small kernel, and a small kernel is a fast kernel.
Do modules slow your kernel down?? When i was using slack 8.1 i just ran a 'make menuconfig' with the stock 2.4.18 kernel, changed the arch, closed out, then ran a 'make oldconfig' , said No to everything and compiled the 2.4.20 kernel.

Now would just changing the arch on the stock 9 kernel show any improvement?? Most of the stuff on here is really compiled into modules anyway.....I just want to get this thing optimzed as quick as it could go. so....

Is it better to have it built in or built as a module?? (like say ppp, sound, i2c, lm_sensors, etc)

Does building modules for stuff you don't have slow it down?? Looking at config for the stock kernel there are ALOT of modules i can scrap out.

Those are the only two questions I have along with the current arch settings. If more performance can be squeezed would be great.

thanks

narusegawa 04-04-2003 03:09 AM

There are a lot of drivers marked as 'M' in make menuconfig.... and just wondering... if in /etc/rc.d/rc.modules NOTHING has been uncommented at all. Then is it safe to get rid of all the drivers that ARE being built as modules?

grub 04-04-2003 05:05 AM

I have a question. How a kernel knows what module to load if it is not built into the kernel.
Will it have an entry in it,
saying this feature(say ntfs support) is selected as a module and needs to be loaded.
Will building unnecessary modules increases the size of the kernel.
(Suppose USB, I dont have any USB devices presently, But my configuration includes module support for USB)
:study:

DaOne 04-04-2003 06:41 AM

If the kernel is compiled with support for a certain feature/hardware (it will be marked with a * in menuconfig), then yes, the size of the kernel increases accordingly. If you just add support as a module (marked with a M), the kernel size is not increased. Some modules will be loaded at boot, so it isn't always necessary to edit /etc/rc.d/rc.modules. However, if you have a module that you need loaded and it does not load by default, then uncommenting it or adding a line for it in rc.modules will usually suffice.

flashingcurser 04-08-2003 11:48 PM

Exellent post.

One note, please correct the spelling of :

make modules_install

the "e" in modules is missing



:)

Aussie 04-09-2003 02:26 AM

Done :-)

Waldi 04-09-2003 02:50 AM

Is it possible to compile and install single module (which was completely missed before) without recompiling and reinstall all modules? Maybe it can be done by inserting parameter (module name or something) to "make modules" and "make modules_install"?

grub 04-09-2003 04:44 AM

Make takes care of compiling only the changed files (modules). If the modules are already compiled, they are not compiled again.

binaryhate 04-09-2003 11:14 AM

Things that make you, "hmm".
 
I've followed the directions posted above; however, when rebooting, it still boots up 2.4.20 kernel.

It states, "loading Linux.old.....".

What have I overlooked?

DaOne 04-09-2003 12:49 PM

I believe you may have something goofy with your lilo.conf...can you post its' contents here?

binaryhate 04-09-2003 05:40 PM

Not a problem.
 
Here it is.

peter@Carbuncle:~$ less /etc/lilo.conf
# LILO configuration file
# generated by 'liloconfig'
#
# Start LILO global section
boot = /dev/hda
append = "hdc=ide-scsi hdd=ide-scsi"
#compact # faster, but won't work on all systems.
#prompt
#timeout = 5
# VESA framebuffer console @ 1024x768x64k
vga = 791
# Normal VGA console
# vga = normal
# VESA framebuffer console @ 1024x768x64k
# vga=791
# VESA framebuffer console @ 1024x768x32k
# vga=790
# VESA framebuffer console @ 1024x768x256
# vga=773
# VESA framebuffer console @ 800x600x64k
# vga=788
# VESA framebuffer console @ 800x600x32k
# vga=787
# VESA framebuffer console @ 800x600x256
# vga=771
# VESA framebuffer console @ 640x480x64k
# vga=785
# VESA framebuffer console @ 640x480x32k
# vga=784
# VESA framebuffer console @ 640x480x256
# vga=769
# ramdisk = 0 # paranoia setting
# End LILO global section
# Linux bootable partition config begins
image = /boot/vmlinuz.old
root = /dev/hda1
label = Linux.old
read-only # Non-UMSDOS filesystems should be mounted read-only for checking
# Linux bootable partition config ends

Aussie 04-09-2003 06:20 PM

You only have an entry for your old kernel in that lilo.conf - vmlinuz.old - you need to add an entry for your new kernel and run lilo to update.

binaryhate 04-09-2003 06:40 PM

Okay, I spoke too soon. I had thought that it was working but didn't look too closely and I went back to work.

Coming back to my machine, I see that it's still 2.4.20.

I grabbed a sysadmin who looked at it and he had me run lilo -v and it returned:

yadda yadda...

Boot image: /boot/vmlinuz
Added Carbuncle *

Boot image: /boot/vmlinuz.old -> vmlinuz-ide-2.4.20
Added Linux.old

/boot/boot.0300 exists - no backup copy made.
Writing boot sector.

Stumped.

My lilo.conf is as follows now:

yadda yadda ...

boot = /dev/hda
append = "hdc=ide-scsi hdd=ide-scsi"
#compact # faster, but won't work on all systems.
#prompt
#timeout = 5
# VESA framebuffer console @ 1024x768x64k
vga = 791
# Normal VGA console
# vga = normal
# VESA framebuffer console @ 1024x768x64k
# vga=791
# VESA framebuffer console @ 1024x768x32k
# vga=790
# VESA framebuffer console @ 1024x768x256
# vga=773
# VESA framebuffer console @ 800x600x64k
# vga=788
# VESA framebuffer console @ 800x600x32k
# vga=787
# VESA framebuffer console @ 800x600x256
# vga=771
# VESA framebuffer console @ 640x480x64k
# vga=785
# VESA framebuffer console @ 640x480x32k
# vga=784
# VESA framebuffer console @ 640x480x256
# vga=769
# ramdisk = 0 # paranoia setting
# End LILO global section
# Linux bootable partition config begins
image = /boot/vmlinuz
root = /dev/hda1
label = Carbuncle
read-only
image = /boot/vmlinuz.old
root = /dev/hda1
label = Linux.old
read-only # Non-UMSDOS filesystems should be mounted read-only for checking
# Linux bootable partition config ends
~
/etc/lilo.conf lines 1-43/43 (END)


R3N3G4D3 04-12-2003 12:32 AM

This is my first time I'm trying to recompile a kernel (cuz kde 3.1 takes about 10 seconds just to start up applications and I don't like other guis). I downloaded slackware online and burned it to cd, then did full install (with all applications etc.), but now when I'm trying to follow your guide and you mentioned going to /usr/src/linux/Makefile with text editor, but when I go to /usr/src the only folder there is rpm (and no files there either), after this I searched my disk for makefile and found about 40 of them (and I have no clue which one is the one I need), could someone help me? Thanks.

Aussie 04-12-2003 01:48 AM

You need to download and untar a kernel.

R3N3G4D3 04-12-2003 11:35 AM

thanks, I've recompiled my kernel, and now my KDE 3.1 opens everything up instantly (used to be up to 20 seconds before), I didn't know kernel would have this much effect on KDE. But there is another problem now. Linux no longer supports sound (and it even gives an error message about that when it boots up) and the internet no longer works. For the internet I think I know what the problem might be, I didn't think I would need to share files across computers so I disabled file sharing with other computers and from other computers, but since I use a router it probabaly thinks of my router as a computer too. So I think I can fix the internet (I hope), but I have no clue what to do about the sound, I think I only disabled one sound option that said I should type lspci -n to see if I was using it, and when I typed it it said that I wasnt using that thing, os I said N for it.

timezero 04-12-2003 07:34 PM

Re: Kernel compiling guide for newbies...
 

Great guide. thanks.

However, my guide does not include 'make menuconfig' 'make clean' and 'make' but 'make mproper' and 'make config' So I was wondering if anyone could tell me the difference?

aaron_n 04-14-2003 10:11 AM

Re: Re: Kernel compiling guide for newbies...
 
Quote:

Originally posted by timezero
Great guide. thanks.

However, my guide does not include 'make menuconfig' 'make clean' and 'make' but 'make mproper' and 'make config' So I was wondering if anyone could tell me the difference?

make mproper is like an aggressive make clean ;)
make config is make menuconfig but text based.

On Another Note:
If, like me, you can't be arsed to deal with modules. Just compile them directly into the kernel (e.g '*' and not 'M' in make menuconfigs selection boxes).
You loose the advantages of dynamically loading and unloading modules/drivers. But I have no need to do that :-)
And to get detailed information on an option in make menuconfig just press "SHIFT + ?" when the option is selected.

Aaron

timezero 04-14-2003 03:03 PM

Re: Re: Re: Kernel compiling guide for newbies...
 
Quote:

Originally posted by aaron_n
make mproper is like an aggressive make clean ;)
make config is make menuconfig but text based.

On Another Note:
If, like me, you can't be arsed to deal with modules. Just compile them directly into the kernel (e.g '*' and not 'M' in make menuconfigs selection boxes).
You loose the advantages of dynamically loading and unloading modules/drivers. But I have no need to do that :-)
And to get detailed information on an option in make menuconfig just press "SHIFT + ?" when the option is selected.

Aaron

Thanks for the reply!

Is it possible to compile the kernel with slackwares standard module configuration but perhaps adding 2 or 3 modules, without having to answer yes or no for every module?

I am also curios why my kernel guide doesn't include "make" after make bzimage? :scratch:

Aussie 04-14-2003 03:30 PM

Make bzImage is the command to make a compressed kernel image.

timezero 04-15-2003 08:28 AM

Quote:

Originally posted by Aussie
Make bzImage is the command to make a compressed kernel image.
Thanks, but,

I meant

make bzimage
make <-- this make

Aussie 04-15-2003 08:53 AM

Because you have already issued the 'make' command, with the bzImage added on to specify a bz2 compressed kernel image, there are a few other options you can use instead of bzImage, see the kernel HOWTO for all the details.

hecresper 04-15-2003 05:44 PM

Is there an online guide/howto that will go into a detailed explanation of ALL the options available during menuconfig?

I'm asking this because, while I can just follow the simple steps mentioned here and other places, there is a whole bunch of other options in there. I'm very curious about what everything means in there. I've followed plenty of basic step-by-step, but I always feel like: huh? what did I just do? Huh! It feels like I'm in drone mode. Monkey see, monkey do!

LOL

Thanks.


All times are GMT -5. The time now is 09:45 PM.