Click to See Complete Forum and Search --> : When is it necessary to Recompile the Kernel?


Alex Ethridge
11-01-2000, 08:31 PM
I don't have a Linux system... yet; but, I do have a question about recompling the kernel. When is it necessary to recompile the kernel and what does it do to recompile the kernel?

Strike
11-01-2000, 09:05 PM
It's rarely necessary to recompile the kernel, assuming all your hardware already works. The only thing that would require recompiling a kernel is if you wanted some core functionality that doesn't exist (like supporting a certain piece of hardware or a certain filesystem, etc).

Recompiling a kernel can make your system run faster by eliminating stuff it doesn't use, it also allows/forces you to pick and choose what things your system can do.

Alex Ethridge
11-01-2000, 09:17 PM
Can I assume that when Linux setup is run, it compiles the kernel to suit your own software choices and existing hardware?

Can I assume also that when you remove hardware or install a new piece of hardware, you would then recompile the kernel?

Let's say I have a Linux system and let's say I sell that system but, keep the hard disk. Let's say I put that hard disk into another system. Would that be a good time to recompile the kernel?

Please explain why or why not.

Recompiling the kernel, is that sort of like when you tell Windows to detect hardware?

[This message has been edited by Alex Ethridge (edited 02 November 2000).]

The_Stack
11-02-2000, 07:08 PM
When Linux setup is run, a default kernel is loaded. The default kernel usually has all of the various device drivers compiled into it so that Linux can support "out of the box" most of the devices you have on your computer.

If you remove hardware, it may not be necessary to recompile your kernel. If you add new hardware, it may be necessary to recompile your kernel if you want the driver to be compiled into your kernel, otherwise if the new hardware has its driver as a loadable module there is no need to recompile your kernel.

If you move a hard drive which has Linux on it to another computer which does not have the same devices, you should be able to at least boot your system, but not all devices may work if support for them was not available as a loadable module or compiled into your kernel; if not all the devices on your new computer work then you will have to recompile your kernel or at least attempt to download and install the drivers as loadable modules.

The most likely reason why a general Linux setup does not automatically detect your devices and automatically recompile the kernel is default kernel already contain all the device drivers, therefore it is redundant doing so. Besides, since you are the system administrator, it is your responsibility to trim (recompile) the default kernel to only support the devices you currently have.

Recompiling the kernel is, in effect, you modifying the kernel by inserting device support in the form of compiled binary code. The end result is device support.'

If you want a detailed academic discussion about the Linux kernel you can go to: http://plg.uwaterloo.ca/~itbowman/CS746G/a1/#Toc_1_1

Alex Ethridge
11-02-2000, 07:43 PM
Thanks, Stack, for the succinct and well-written explanation.

I don't have a running Linux system yet and it sure is nice to be able to learn all these things. I guess I understand the kernel a little better now. From what you have written I am assuming that, aside from being the disk operating system, the kernel contains the support for the peripheral hardware--floppy and hard drives, SCSI controllers, modems, network cards, etc. I also understand that if it isn't already compiled into the kernel, or if we prefer in some cases, we can optionally load the drivers much the same as we used to load all our device drivers under MS-DOS.

I've been reading in the threads here about optimizing the kernel for speed. From what I gather, it seems that some users think they can speed up their systems by removing some unneeded portions of the kernel. From what you wrote about the default kernel supporting almost any machine, I guess there are a lot of things there that aren't needed on all systems.

Over the years, I have developed as a user who constantly changes hardware and software (hardware more than software) and being able to update my kernel is something I am going to have to learn a lot about, and very early on. I have 4 computers on a network and none of them over 4 months old. When I have a client who needs a system, I usually pull the hard disk from a system, insert a new one and deliver it to him. This ensures that the customer quickly gets a tried and true working system with no bad hardware; but, it will also cause havoc on a Linux-loaded hard disk when I insert it into another box--unless I learn very early how to recompile.

If any of what I have written indicates I misunderstand anything, someone please correct me.

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

compunuts
11-02-2000, 10:00 PM
Originally posted by Alex Ethridge:
the kernel contains the support for the peripheral hardware--floppy and hard drives, SCSI controllers, modems, network cards, etc.
It’s somewhat true but most of the drivers are loaded as loadable modules rather than directly into the kernel. The advantages is that kernel will be much more smaller which means faster to run. You only need to load once for the driver such as NIC but kernel has to be accessing every time your computer does something so that you don’t want those driver support codes getting in your way.

When I have a client who needs a system, I usually pull the hard disk from a system, insert a new one and deliver it to him. This ensures that the customer quickly gets a tried and true working system with no bad hardware; but, it will also cause havoc on a Linux-loaded hard disk when I insert it into another box--unless I learn very early how to recompile.

In your specific case, default kernel is even a better idea than recompiling kernels. So that when you move your drive to a new machine, you do not need to recompile it. All you need to do is re-configure what hardware support drivers are needed to load when the system start up. From what I’ve seen so far, recompiling kernel is best on old systems. The new high-speed systems can handle even bulky kernel with ease http://www.linuxnewbie.org/ubb/smile.gif. I’m not saying you will not have any advantage with recompiling kernel. The performance gain is not significant on high-end already-over-killed systems.
If you recompile to run optimal on the system with minimal kernel size and if that customer needed to upgrade hardware, may be one hardware goes bad or something, then the customer needs to recompile to have the hardware support which may not be up to the challenge for that customer to recompile the kernel. I don’t know. I never wanted to call anything for tech support. http://www.linuxnewbie.org/ubb/biggrin.gif

Bert
11-02-2000, 10:08 PM
OK, I'll ask the question. How much faster is a lean mean (recompiled) kernel vs a default kernel? Is it worth the trouble?

Thanx,
Bert

compunuts
11-02-2000, 10:21 PM
Recompiling the kernel is not that hard. Have you seen many people doing it? http://www.linuxnewbie.org/ubb/wink.gif
Personally, I don't see much in difference with my systems although many people likes to brag about how fast their system becomes. I have P II 300 with 128 MB of RAM.

TaeShadow
11-02-2000, 11:58 PM
I've got a PIII 500 with 128 MB. I did not notice any significant difference after recompiling my kernel.


Tae

Henrycoffin
11-03-2000, 05:42 AM
I think the speed question depends on what your going to do with the system, I am running a database server and noticed a considerable difference after recompiling the kernel but no particular difference on my desktop pc.

mastersibn
11-03-2000, 06:12 AM
compunuts, I'm going to have to disagree with you on this one.

I compiled a new kernel this afternoon (When is it necessary? When the name of the day is one ending in the letter 'y' http://www.linuxnewbie.org/ubb/wink.gif) and in a radical departure from what I do, the first thing I did was kill loadable module support. I was running kernel 2.2.17 at the time, and was compiling the same version for the exact same hardware. In short, I was just messing around with my kernel to see what would happen if I compiled it without modules.

The image was some 410kB before I recompiled; it was 581kB afterward. This may be telling evidence that modules make a smaller kernel, but the modules I had compiled for that version added up to (yes) 760kB. That means the kernel with modules was almost twice the size of the exact same kernel with no modules. Of course, when you compile a kernel and modules, the image is compressed while the modules are not, but that's neither here nor there... http://www.linuxnewbie.org/ubb/biggrin.gif

Thing is, modules tend to be a bit slower than 'built-ins,' as I hear. I've heard they can be up to 10% slower than built-in components. So I have a faster, smaller system with the exact same functionality that I had in the larger, slower one that had modules wherever possible. The only filesystems my old kernel had built in were ext2. The others (iso9660, nfs, msdos) were modules. Ide CDROM support was a module. I was up to my eybrows in modules, and they're a pain in the *** to maintain. I learned an important lesson: It's just not worth it.

I had a custom rc.modules depending on the output of `uname -r` run when I booted that would load all my modules. Why load all of them? Because I'm going to use at very best -most- of them. Sure, I don't burn CDs very often, but I have a few extra cycles of cpu and bytes of ram to spare for a module that i'm not using "yet." Now instead of screwing around with modprobe, and dealing with all the module problems, the system runs better than ever; and the kernel is pretty damned small, too. http://www.linuxnewbie.org/ubb/biggrin.gif (how small? occupies about 1.5mB of RAM when running if I'm not mistaken)

I'm sure you can make some nice small kernels with modules. But I can make more hassle free, faster (and smaller) kernels without them. There will always be a use for modules, and I don't intend to completely skip them; modules have many good uses (graphic acceleration anybody?) because it makes more sense to compile a new module than it does to compile a whole new kernel. Frankly, though, I wouldn't care. Like I said: I only compile a kernel on days ending in 'y.' http://www.linuxnewbie.org/ubb/biggrin.gif

------------------
grab my gnupg key (http://jove.prohosting.com/~msibn/sibn-p.asc) if you feel so inclined.


cAPS lOCK? wHAT cAPS lOCK?
I cna ytpe 300 wrods pre mniuet!!!

Muzzafarath
11-03-2000, 06:12 AM
Originally posted by Bert:
OK, I'll ask the question. How much faster is a lean mean (recompiled) kernel vs a default kernel? Is it worth the trouble?

Thanx,
Bert[/B]

There is no trouble involved with recompiling a kernel. If you're careful (ie think about what you include in your kernel and don't remove the old - working - kernel before you know for sure that the new kernel works) nothing bad can happen http://www.linuxnewbie.org/ubb/wink.gif. I have recompiled a couple of times now, and only once have the new kernel not worked (forgot to include support for binaries http://www.linuxnewbie.org/ubb/wink.gif). What I did was boot the old working kernel and recompile again. The whole procedure doesn't need to take more than 10 minutes.

[This message has been edited by Muzzafarath (edited 03 November 2000).]