PDA

View Full Version : building a custom kernel [FC2]


rico
2nd June 2004, 12:43 AM
hi everybody, i'm a linux fan (with an average knowledge) and a happy FC2 newbie (moving from the ugly Mandrake) and it would be unusual if my first post is about compiling a custom kernel. i already performed this operation with decent results (never got a kernel panic) but i feel i'm doing it in a wrong way.

i want to recompile it for the following reasons: 1) solve the 4kb STACKS issue with my NVIDIA drivers; 2) optimizing it for my Athlon CPU; 3) let my USB pen drive recognized (scsi emulation and USB mass storage); 4) activate UDF packet writing support and other fine tunings; 5) remove (or build as modules) unneeded stuff.

the last time i did all the work system seemed to boot normally but I had to put the same initrd IMG file of the old kernel in the GRUB. how can I build a new initrd image for my custom kernel? is there a complete guide (step-by-step) to compile a 2.6.x kernel? or maybe can you help me explaining it here? should I recompile my 2.6.5 FC2 kernel or compile a 2.6.6 one? thank you very much to all the community, I love Fedora! :)

kb2qzv
2nd June 2004, 12:53 AM
an interesting feature they've introduced is:
make --help. You can start with:
make allmodconfig - which will produce a workable .config file with as much modules as is possible selected.

make install will produce a initrd (I think) and it will be installed into /boot partition on FC2. But I am not betting my money on that:-)

rico
2nd June 2004, 01:19 AM

make install will produce a initrd (I think) and it will be installed into /boot partition on FC2. But I am not betting my money on that:-)

it's not true, unfortunately i can't get any initrd image from "make install". thanks anyways

jtang613
2nd June 2004, 02:14 AM
Compiling a kernel is by no means easy or fool-proof. But I've done it more than a few times. And really, there's no substitue for practices and your own research on this topic.

Steps you'll want to follow:
- make clean (to remove old files)
- make mrproper (to remove stubborn stuff)

- make xconfig
or
- make menuconfig (to set your kernel options, use one or the other)

- (edit the EXTRAVERSION line in Makefile so you don't overwrite an existing kernel)
- make modules (compile your modules first)
- make modules_install (put them in their place)
- make (compile everything else)
- make install (install the new kernel)

I'm sure some may disagree with a few steps, saying they are needless... But this has always worked well for me.

You will also find your current kernel config in /boot/config-2.6.xxx. You can load it using the menu in xconfig or menuconfig. It's usually a good place to start.

make install DOES in fact build an initrd AND setup your grub.conf or lilo.conf. As long as you enable initrd support in your kernel config. It also copies all necessary files to the /boot directory.

You'll only find the option to disable 4k stacks in a standard kernel source -- the one you get from www.kernel.org. It's located in the 'Kernel Hacking' section. I've had no troubles getting my GF4-Ti4200 up and running in FC2 with kernel-2.6.6.

There are also some kernel options that will break Fedora if not compiled as modules (ALSA, NIC drivers, etc). And some that should be statically compiled (initrd, and a few others). Best bet is to compile modules of anything you're unsure about.

Hope this helps a little,
jt

rico
2nd June 2004, 03:21 AM
thank you very much, i'm trying the way you suggest and it seems to work :)

by the way I found this Kernel-Build HOW-TO which seems good and updated: http://www.digitalhermit.com/linux/Kernel-Build-HOWTO.html

lafrad
13th June 2004, 04:18 AM
Originally posted by jtang613
Compiling a kernel is by no means easy or fool-proof. But I've done it more than a few times. And really, there's no substitue for practices and your own research on this topic.

Steps you'll want to follow:
- make clean (to remove old files)
- make mrproper (to remove stubborn stuff)

- make xconfig
or
- make menuconfig (to set your kernel options, use one or the other)

- (edit the EXTRAVERSION line in Makefile so you don't overwrite an existing kernel)
- make modules (compile your modules first)
- make modules_install (put them in their place)
- make (compile everything else)
- make install (install the new kernel)

I'm sure some may disagree with a few steps, saying they are needless... But this has always worked well for me.

You will also find your current kernel config in /boot/config-2.6.xxx. You can load it using the menu in xconfig or menuconfig. It's usually a good place to start.

make install DOES in fact build an initrd AND setup your grub.conf or lilo.conf. As long as you enable initrd support in your kernel config. It also copies all necessary files to the /boot directory.

You'll only find the option to disable 4k stacks in a standard kernel source -- the one you get from www.kernel.org. It's located in the 'Kernel Hacking' section. I've had no troubles getting my GF4-Ti4200 up and running in FC2 with kernel-2.6.6.

There are also some kernel options that will break Fedora if not compiled as modules (ALSA, NIC drivers, etc). And some that should be statically compiled (initrd, and a few others). Best bet is to compile modules of anything you're unsure about.

Hope this helps a little,
jt

Is there a llist or whaughtnaught of these things that need to be compiled as modules?

jtang613
14th June 2004, 04:55 AM
Not that I know of. Generally, you'll only want to statically compile those modules that are needed in order to load the kernel and activate those devices required to do so. Everything else can be compiled as a loadable module.

For instance, if you use Reiserfs as your root filesystem and don't statically compile the reiserfs module, you may get a kernel panic because the reiserfs module exists on a reiserfs partition, but the kernel can't load it because it doesn't yet know how to access it. OK, that probably wasn't clearest example, but I think it gets the point across.

Another example. Suppose you have a SBLive soundcard and you decide to statically compile the snd-emu10k1 modules. Fedora will report that soundcard init failed because it looks for the loadable module on bootup. Same for network adapters, etc.

Refer to the default /boot/config-x.x for an idea of what needs to be statically compiled and what should be a loadable module.