Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[FAQF] KC: Kernel Compilation
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Fri Nov 22, 2002 6:00 am    Post subject: [FAQF] KC: Kernel Compilation Reply with quote

This thread is to collect information for the Kernel Compilation section of the new FAQ forum. Feel free to add answers to any of the questions here, or submit new questions that you think should be included in the Kernel Compilation section. Here are some questions to get us started:

Q1. I made a mistake compiling my kernel and now my computer won't boot. What can I do now?

Q2. What is devfs? Do I really need it in my kernel? How do I enable it?

Q3. Networking worked during installation, but now that I compiled my own kernel, it doesn't work anymore. What's wrong?

Q4. I compiled a new kernel, but my changes aren't taking effect. How do I install my new kernel?

Q5. I get errors about unresolved symbols when I'm compiling my kernel. How do I get rid of them?

Q6. Which of the various kernel sources (gentoo-sources, vanilla-sources, etc.) are right for me?

Q7. How do I know when to compile something into the kernel, and when should I compile it as a module?

Q8. How do I install a new kernel while still keeping my current one around so that I can use it if necessary?

Q9. How do I install multiple kernel versions alongside one another without causing problems?

Q10. I'm upgrading my kernel sources. Can I use my old configuration? If so, how?

Q11. I've never compiled a kernel before and I'm totally lost. Are there any good guides? How do I get information about what all these options mean?

Q12. I've changed some hardware in my computer. What changes do I need to make to my kernel?

Q13. I just installed a new kernel and now I'm getting a panic at boot time trying to mount the root partition. How do I fix this?

Q14. Why isn't the kernel being compiled with the CFLAGS that I set in /etc/make.conf?

Q15. I just compiled a new kernel and now my computer reboots instantly at startup. Why and how do I fix it?

NOTE: Questions that are links have candidate answers already in their own threads.
_________________
For every higher wall, there is a taller ladder


Last edited by rac on Wed Feb 12, 2003 9:06 pm; edited 7 times in total
Back to top
View user's profile Send private message
yokem55
Guru
Guru


Joined: 18 Apr 2002
Posts: 360
Location: Oregon

PostPosted: Fri Nov 22, 2002 9:49 am    Post subject: Reply with quote

Q7. How do I know when to compile something into the kernel, and when should I compile it as a module?

First of all, if the option is required to boot the system, then it needs be compiled into the kernel. This includes drivers for your ide or scsi controller and the filesystem driver for your root filesystem. If these options are not built into the kernel, then the kernel can't access your hard drives to continue booting the system. Other options that *should* be compiled into the kernel include acpi or apm support (you cannot have both in the kernel at the same time). Pretty much everything else that can be compiled as a module can be used as a module without much problem.
Back to top
View user's profile Send private message
rbacon2
n00b
n00b


Joined: 19 Sep 2002
Posts: 21

PostPosted: Fri Nov 22, 2002 10:55 am    Post subject: Reply with quote

Q8. How do I install a new kernel while still keeping my current one around so that I can use it if necessary?

Once your new kernel is compiled, rename your current one to something snappy like bzImage_old then copy your new one from the source tree to the boot partition.
open /boot/grub/grub.conf or /boot/grub/menu.lst for editing and add a section for your old kernel.
That's it at the next power up you'll be able to choose the kernel you need.
_________________
Cheers,
Richard
Back to top
View user's profile Send private message
rbacon2
n00b
n00b


Joined: 19 Sep 2002
Posts: 21

PostPosted: Fri Nov 22, 2002 10:59 am    Post subject: Reply with quote

Q10. I'm upgrading my kernel sources. Can I use my old configuration? If so, how?

In /usr/src/linux you'll find the configuration file stored as .config, copy this to the new source tree before running your chosen kernel config.

Run through all the kernel sections anyway as there may be more suitable selections in your new sources, but most of the work will already be done.
_________________
Cheers,
Richard
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Fri Nov 22, 2002 6:48 pm    Post subject: Reply with quote

Thanks a lot to everybody who has participated so far. This was much more much sooner than expected. A couple of general comments: please address only one question per post. Eventually, once these posts are formatted and finished, they will be split into their own threads in the FAQ forum, and having multiple questions in a single post makes that more complicated.

Although focusing on GRUB is understandable and reasonable, I think it would be good if we could incorporate a few comments for people who are using other bootloaders, such as LILO and yaboot (those are the only others I've seen mention of on the forums - the Sparc and Alpha people might be using something else).

@rbacon2, it might be nice to make some mention of the "oldconfig" target and its function in the answer to Q10.

EDIT: yokem55's first answer to Q1 has been split. See first post.
_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Fri Dec 06, 2002 8:29 pm    Post subject: Reply with quote

phypor, for KC8 and KC9, can you add some stuff about how /lib/modules directories work, and potential pitfalls of having things conflicting in there?
_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
_SkeLeToN_
Guru
Guru


Joined: 12 Sep 2002
Posts: 506
Location: Montreal,Canada

PostPosted: Fri Dec 06, 2002 9:57 pm    Post subject: Reply with quote

Quote:
Q9. How do I install multiple kernel versions alongside one another without causing problems?


Also what about the /usr/src/linux link ??? when you have multiple kernel you need to change the link if you want for exemple include sound support with alsa for this specific kernel. A way to change that automaticaly ???
Back to top
View user's profile Send private message
ebrostig
Bodhisattva
Bodhisattva


Joined: 20 Jul 2002
Posts: 3152
Location: Orlando, Fl

PostPosted: Sat Dec 07, 2002 1:36 am    Post subject: Reply with quote

_SkeLeToN_ wrote:
Quote:
Q9. How do I install multiple kernel versions alongside one another without causing problems?


Also what about the /usr/src/linux link ??? when you have multiple kernel you need to change the link if you want for exemple include sound support with alsa for this specific kernel. A way to change that automaticaly ???


I can't get this to make sense.

I guess you refer to the symlink between /usr/src/linux/include/linux (or asm-i386) and /usr/include/linux (or asm). This is only needed when compiling programs that needs version specific header files. This can be taken care of through an rc script (etc/conf.d/local.start).

For some reason (I can't remember why any longer, been using Linux too long) I have always named my kernels:
vmlinuz-2.4.19, vmlinuz-2.5.50 and so forth. This makes it easy to have multiple kernels and I now instantly which kernel version it is :)

Erik
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Sat Dec 07, 2002 7:16 am    Post subject: Reply with quote

I think Skeleton is talking about the fact that some kernel module ebuilds (alsa, nvidia-kernel, lm-sensors) rely on /usr/src/linux pointing to the sources for the kernel to build with, and if that points to different sources than you're running, bad things happen.
_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
pilla
Administrator
Administrator


Joined: 07 Aug 2002
Posts: 7212
Location: Pelotas, BR

PostPosted: Sat Dec 07, 2002 6:34 pm    Post subject: Reply with quote

Q13. I just installed a new kernel and now I'm getting a panic at boot time trying to mount the root partition. How do I fix this?

First, you'll need to boot again using a previous kernel backup (or the installation CD, if you haven't made a backup of your kernel). Then, you must verify if your kernel configuration has the correct file system for your root partition. For example, if your / file system is ext3, you need to activate it in File Systems->Ext3 journalling file system support. Make sure it is not compiled as a module but inside the kernel. Compile your kernel again and install it following the regular instructions.
Back to top
View user's profile Send private message
pilla
Administrator
Administrator


Joined: 07 Aug 2002
Posts: 7212
Location: Pelotas, BR

PostPosted: Sat Dec 07, 2002 6:35 pm    Post subject: Reply with quote

I think that this is the most usual situation, but I may be wrong. I didn't want to make it overly complex, so I kept it very basic. If you think it is not enough, I can try to be more comprehensive.

Bloody Bastard wrote:
Q13. I just installed a new kernel and now I'm getting a panic at boot time trying to mount the root partition. How do I fix this?

First, you'll need to boot again using a previous kernel backup (or the installation CD, if you haven't made a backup of your kernel). Then, you must verify if your kernel configuration has the correct file system for your root partition. For example, if your / file system is ext3, you need to activate it in File Systems->Ext3 journalling file system support. Make sure it is not compiled as a module but inside the kernel. Compile your kernel again and install it following the regular instructions.
Back to top
View user's profile Send private message
pilla
Administrator
Administrator


Joined: 07 Aug 2002
Posts: 7212
Location: Pelotas, BR

PostPosted: Sat Dec 07, 2002 6:45 pm    Post subject: Reply with quote

Q12. I've changed some hardware in my computer. What changes do I need to make to my kernel?

You may disable support for hardware that you don't have anymore and enable support for the new hardware. Keep a backup of your kernel configuration (.config), so you can compare to your new configuration if any problems arise.
Back to top
View user's profile Send private message
phypor
n00b
n00b


Joined: 25 Jun 2002
Posts: 68
Location: Texas

PostPosted: Sat Dec 07, 2002 7:18 pm    Post subject: Reply with quote

rac wrote:
phypor, for KC8 and KC9, can you add some stuff about how /lib/modules directories work, and potential pitfalls of having things conflicting in there?


Couldn't think of any obvious pitfalls...
but then I don't have many different kernel versions on the same system either so my experience is limited. I did get this tho:

KC16. What is /lib/modules and how is it used?

This applies only if you use kernel modules.

/lib/modules contains subdirectories for each current kernel version you have installed.

/lib/modules/2.4.19-gentoo-r7
/lib/modules/2.4.19-gentoo-r9
/lib/modules/2.4.19-vanilla

On boot /etc/init.d/modules calls /usr/sbin/update-modules which gentoo's
packages use for most modules. /etc/modules.autoload can be used by you to handle
any modules you need to load on boot. For instance, I have NVdriver there for
nvidia's video card module.
_________________
ALWAYS stay away from tanks enguled in fire.
- 2000 Emergency Response Guidebook, pg307
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Sat Dec 07, 2002 8:24 pm    Post subject: Reply with quote

phypor wrote:
Couldn't think of any obvious pitfalls...
If you have two kernels from the same source, but with different configs, they will share a directory in /lib/modules, which can hose things, making the "backup" kernel unbootable. Possible solutions include stashing /lib/modules stuff somewhere, changing the kernel version string in the source tree temporarily, etc. None of this matters when having kernels with different versions, but sometimes people try new configuration settings, but want to have a fallback, but they're using the same kernel version, and the fallback fails.
_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
pilla
Administrator
Administrator


Joined: 07 Aug 2002
Posts: 7212
Location: Pelotas, BR

PostPosted: Sat Dec 07, 2002 8:59 pm    Post subject: Reply with quote

But critical hardware support necessary to boot is usually inside the kernel (at least for Gentoo, has somebody found mkinitrd somewhere?). I think that the sollution for this problem should be resolved by the ebuild that installed the sources.

rac wrote:
phypor wrote:
Couldn't think of any obvious pitfalls...
If you have two kernels from the same source, but with different configs, they will share a directory in /lib/modules, which can hose things, making the "backup" kernel unbootable. Possible solutions include stashing /lib/modules stuff somewhere, changing the kernel version string in the source tree temporarily, etc. None of this matters when having kernels with different versions, but sometimes people try new configuration settings, but want to have a fallback, but they're using the same kernel version, and the fallback fails.
Back to top
View user's profile Send private message
UnderDog138
n00b
n00b


Joined: 03 Dec 2002
Posts: 67
Location: Dallas, TX, USA

PostPosted: Sun Dec 08, 2002 5:34 am    Post subject: Reply with quote

If anybody cares, I had a problem with the /usr/src/symlink messing up my NVdriver module when I switched kernels and I notice other people have similar problems so I wrote this little diddy. Run it before rebooting when switching to another kernel.

Code:

#!/bin/sh

# Enter the directory name of the kernel source in /usr/src
# to switch the symlink to
#
# Remember to run this before rebooting when switching kernels

# Usage
# bash# kernel-linkswap linux-2.4.20

rm -f /usr/src/linux
echo "Removed old symlink /usr/src/linux"
ln -s "/usr/src/$1" /usr/src/linux
echo "Added new symlink /usr/src/linux -> /usr/src/$1"


It's an automated solution, so some of you may want this.
_________________
Adopt an unanswered post today!
Back to top
View user's profile Send private message
_SkeLeToN_
Guru
Guru


Joined: 12 Sep 2002
Posts: 506
Location: Montreal,Canada

PostPosted: Mon Dec 09, 2002 5:17 am    Post subject: Reply with quote

rac wrote:
I think Skeleton is talking about the fact that some kernel module ebuilds (alsa, nvidia-kernel, lm-sensors) rely on /usr/src/linux pointing to the sources for the kernel to build with, and if that points to different sources than you're running, bad things happen.


Yes that's exactly what I was talking about. Sorry if my post was confusing ...

Is there a way when you select the the kernel you want at boot to change the symlink for /usr/src/linux with the one you choose on boot ??
Back to top
View user's profile Send private message
UnderDog138
n00b
n00b


Joined: 03 Dec 2002
Posts: 67
Location: Dallas, TX, USA

PostPosted: Mon Dec 09, 2002 5:52 am    Post subject: Reply with quote

I considered doing that but I couldn't figure out how so I just wrote a shell script to do it before I reboot.
_________________
Adopt an unanswered post today!
Back to top
View user's profile Send private message
carambola5
Apprentice
Apprentice


Joined: 10 Jul 2002
Posts: 214
Location: Madtown, WI

PostPosted: Sat Dec 21, 2002 7:07 pm    Post subject: Reply with quote

To keep track of what your kernels do and when they were used, I suggest creating a text file in your /boot partition that keeps track.
Code:

FILENAME        USED UNTIL        REASON GOING TO
========--------==========--------===============
bzImage.01      12/02/2002        Initial kernel
bzImage.02      12/03/2002        USB Mass Storage
bzImage.03      12/10/2002        Last one didn't work
bzImage.04                        removed IDE-CDROM (for CDRW)

_________________
Get Firefox!

Proper Web Development

I'm done at 999.
Back to top
View user's profile Send private message
SeJo
Retired Dev
Retired Dev


Joined: 08 Oct 2002
Posts: 298
Location: Belgium

PostPosted: Mon Dec 23, 2002 9:38 am    Post subject: Q15. I just compiled a new kernel and now my computer reboot Reply with quote

Q15. I just compiled a new kernel and now my computer reboots instantly at startup. Why and how do I fix it?

You might have forgoten to update your bootloader. Most of the time this happens after upgrading a kernel version.
boot using install-cd or bootupdisk
mount your / and your /boot partition.
chroot to your / partition.
configure your bootloader.

lilo: as root: nano /etc/lilo.conf and make sure you set the link to the correct kernel
grup: as root: grub, make sure you set the link to the correct kernel

Also you might want to heck if the bzImage in the /boot section is the correct one. I always use a ls -all /boot/bzImage and check the time and the size..
Back to top
View user's profile Send private message
Sargonas
Apprentice
Apprentice


Joined: 10 Feb 2003
Posts: 213
Location: user@localhost

PostPosted: Wed Feb 12, 2003 6:53 pm    Post subject: Reply with quote

I wrote this because of a not exsisting one in the faq but didnt see the previous post until searching for a place to put this. Sorry.

[faq] KC10: I'm upgrading my kernel sources. Can I use my old configuration? If so, how?

Once you have emerged the new kernel there are several new ways to use your old config for you your new kernel pending that you have saved you your .config file from your old kernel or havent deleted the source from your last install.

First thing to do is copy ( /usr/src/linux-2.(old version)/.config or /boot/config-(version) ) to /usr/src/linux-2.(spify new version)/.config

This will give you access to your old config.

Now if you do any of the make *config you should have the ability to load that config:

make oldconfig: This will configure the kernel from an old configuration file .config if it exsist otherwise will use arch/<your arch>/depconfig recommended that you run menu or x config after this to check for any changes.

make menuconfig: Will first attempt to load .config, that failing it will load arch/<your arch>/depconfig This provides you with an easier option of configuring and has option for loading configs and saving.

make xconfig: Will load .config, failing will load defaults, this is probably the easiest for beginners because it will show everything in a nice pretty format.

Note on xconfig: requires xfree86 to be started + tcl/tk and wish

after you have loaded that up then just continue compiling as normal:

i.e. make clean dep bzImage modules modules_install install


Note: clean and install are not required but are recommended:

clean: clears all previously compiled modules and kernels from this source

install: moves bzImage to /boot and names it according to the kernel name and will attempt to update lilo for you.( I dont use lilo so I anwser no to this ) this will also copy your config to /boot/config-kernelname that way you will still have it no matter what you do to /usr/src/linux* and if this is a recompile of an old kernel that is already in boot it will move it to vmlinuz-(version).old

Be sure to update /etc/modules.autoload adding any modules ( that you have changed ) you want loaded at boot.

update grub or lilo and reboot. Enjoy your spify new kernel!
_________________
I do not consider it an insult, but rather a compliment to be called an agnostic. I do not pretend to know where many ignorant men are sure -- that is all Agnosticism means. - Clarence Darrow
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Wed Feb 12, 2003 8:54 pm    Post subject: Reply with quote

Apologies to all participants in this thread, especially Sesshomaru. I must have fallen asleep and not noticed the last several posts. We've decided to go with IWBCMAN's KC10.

@SeJo: for KC15 I was basically looking for http://forums.gentoo.org/faq.php#15.
_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
buckyball
n00b
n00b


Joined: 28 Oct 2002
Posts: 14
Location: Fremont, CA

PostPosted: Wed Feb 12, 2003 9:49 pm    Post subject: Maintaining multiple kernels from the same tree Reply with quote

Something that I haven't seen mentioned here is how you maintain multiple, serial copies of kernels (and their associated modules) built from the same source tree so that you can incrementally "tweak" the config of your kernel while maintaining one or more working "fallback" copies.

The way I do it is to modify the "EXTRAVERSION = " line in /usr/src/linux/Makefile to have something like:

Code:

VERSION = 2
PATCHLEVEL = 4
SUBLEVEL = 20
EXTRAVERSION = -0


This will result in a kernel with the internal revision 2.4.20-0 whose modules will be installed to /lib/modules/2.4.20-0. I copy the kernel image to /boot/bzImage-2.4.20-0 and add a new section to /boot/grub/grub.conf (or 'menu.lst' for older systems).

It's also a prudent idea (as mentioned elsewhere here) to make a backup copy of the /usr/src/linux/.config file to /boot/config-kernel-version so that you can revert to the configuration of a previously-built kernel if needed.

Finally, for machines with Nvidia support, ALSA, etc., I re-emerge those items to get the proper modules in /lib/modules/kernel-version.

The next time I want to adjust the kernel in some way, I simply bump the EXTRAVERSION value by 1 before the
'make dep && make clean bzImage modules modules_install'.

Hope this helps someone. It's sure useful for me.
_________________
Buckyball
If it doesn't fit, force it --
if it breaks, it needed fixing anyway!
Back to top
View user's profile Send private message
dimde
n00b
n00b


Joined: 09 Feb 2003
Posts: 2

PostPosted: Sat Feb 22, 2003 4:10 pm    Post subject: Reply with quote

Please add http://forums.gentoo.org/viewtopic.php?t=8407&highlight=inital+console to KC15.

I moved my working gentoo installation to another HD and forgot to copy /dev.
So I messed around with new Kernels, etc... for more than a week until I found this thread about the empty /dev directory.

Here's what you have to do:

Code:

boot from the LiveCD
mkdir /mnt/gentoo
mount /dev/hdxy (your existing-installation's root dir)
cd /tmp
tar -xvjpf /cdroot/nocompress/stage1-*.tbz2
cp -a /tmp/dev /mnt/gentoo/dev
umount /mnt/gentoo
reboot
Back to top
View user's profile Send private message
discomfitor
l33t
l33t


Joined: 21 Feb 2003
Posts: 927
Location: None

PostPosted: Sat Feb 22, 2003 6:30 pm    Post subject: Reply with quote

Q5. I get errors about unresolved symbols when I'm compiling my kernel. How do I get rid of them?

From what I've seen, this is usually caused by a dependency problem. You've probably enabled some option (like mousedev) without enabling another option that it depends on (like keybdev) and so it fails to compile. Check over your configuration and see if you're missing something.

Also, if this (unresolved symbols) happens to your modules when you try to load them, you can fix it by doing:
Code:
cd /usr/src/linux
cp .config ~/
rm -rf /lib/modules/{kernel name here}
make mrproper
cp ~/.config ./
make menuconfig
exit menuconfig
make dep && make clean bzImage modules modules_install
cp arch/{arch}/boot/bzImage /{boot}/bzImage


Hope this helps!
_________________
There is no substitute for experience.
Imperfection indicates a lack of effort.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum