# [FAQF] KC11:  Kernel compiling for the beginner.

## smouge

Nice tips,

I would add to these tips that it is very handy when you have a working kernel, to save the new kernels you make with a different name and to adapt lilo in such a way can boot from both kernels.

For example, my lilo looks like this:

```
# $Header: /home/cvsroot/gentoo-x86/sys-apps/lilo/files/lilo.conf,v 1.3 2002/09/30 00:55:18 woodchip Exp $

# Author: Ultanium

# Start LILO global section

menu-scheme=Wb

boot = /dev/hda

prompt

map = /boot/System.map

lba32

timeout=150

delay = 50

default = GentooNew

vga = normal   # Normal VGA console

# End LILO global section

# Linux bootable partition config begins

   image = /boot/bzImage

   root = /dev/hda3

   #root = /devices/discs/disc0/part3

   label = Gentoo2420

   read-only # read-only for checking

   append = "hdd=ide-scsi"

# Linux bootable partition config ends

# Linux bootable partition config begins

   image = /boot/bzImageOpenMosix

   root = /dev/hda3

   label = GentooOpenMosix

   read-only # read-only for checking

   append = "hdd=ide-scsi"

# Linux bootable partition config ends

# Linux bootable partition config begins

   image = /boot/bzImageNew

   root = /dev/hda3

   label = GentooNew

   read-only # read-only for checking

   append = "hdd=ide-scsi"

# Linux bootable partition config ends

```

and I have made a small script: /usr/src/makekernel

```
#!/bin/bash

usage() {

cat << FOO

usage: makekernel 2.4.19

       makekernel 2.4.20

       makekernel 2.4.20-openmosix

note:

examples:

      

FOO

   exit 1

}

kernel2419() {

   rm -f /usr/src/linux

   ln -s /usr/src/linux-2.4.19 /usr/src/linux

   cd /usr/src/linux 

   #rm -Rf /lib/modules/2.4.19/kernel/*

   cp .config /boot/.config

   make mrproper 

   cp /boot/.config .config 

   make menuconfig 

   make dep && make clean bzImage modules modules_install 

   cp /boot/bzImageNew /boot/bzImageNew.old 

   cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImageNew

   cp .config /boot/.config_2.4.19

   emerge unmerge nvidia-glx

   emerge unmerge nvidia-kernel

   emerge nvidia-glx

   emerge nvidia-kernel

   lilo -v

   exit 1

}

kernel2420() {

   rm -f /usr/src/linux

   ln -s /usr/src/linux-2.4.20 /usr/src/linux

   cd /usr/src/linux 

   #rm -Rf /lib/modules/2.4.20/kernel/*

   cp .config /boot/.config

   make mrproper 

   cp /boot/.config .config 

   make menuconfig 

   make dep && make clean bzImage modules modules_install 

   cp /boot/bzImageNew /boot/bzImageNew.old 

   cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImageNew

   cp .config /boot/.config_2.4.20

   emerge unmerge nvidia-glx

   emerge unmerge nvidia-kernel

   emerge nvidia-glx

   emerge nvidia-kernel

   lilo -v

   exit 1

}

kernel2420openmosix() {

   rm -f /usr/src/linux

   ln -s /usr/src/linux-2.4.20-openmosix-r2 /usr/src/linux

   cd /usr/src/linux 

   #rm -Rf /lib/modules/2.4.20/kernel/*

   cp .config /boot/.config

   make mrproper 

   cp /boot/.config .config 

   make menuconfig 

   make dep && make clean bzImage modules modules_install 

   cp /boot/bzImageNew /boot/bzImageNew.old 

   cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImageNew

   cp .config /boot/.config_2.4.20

   emerge unmerge nvidia-glx

   emerge unmerge nvidia-kernel

   emerge nvidia-glx

   emerge nvidia-kernel

   lilo -v

   exit 1

}

# Main program loop starting here

if [ `id -u` -ne 0 ]

then

   eerror "${0}: must be root."

   exit 1

fi

if [ $# -lt 1 ]

then

   usage

fi

if [ "$1" = "2.4.19" ] ; then

   kernel2419

elif [ "$1" = "2.4.20" ]; then

   kernel2420

elif [ "$1" = "2.4.20-openmosix" ]; then

   kernel2420openmosix

fi

```

In this way I can quickly make a new kernel. Each compiled kernel is saved as /boot/bzImageNew

If the new kernel doesn't run, I can still start the system with the older 2.4.19 or 2.4.20, gentoo-sources, openmosix  etc. kernel.

I hope you find this usefull.

```

```

----------

## wilburpan

Thanks for the suggestion.  I incorporated it into my FAQ.

----------

## Stieltje

I have 2 kernels now, gentoo-sources and ck-sources, took me a little while to figure out how to get my modules working in the later emerged kernel, ie ck-sources. (setting the symlink linux to my ck-sources directory) . happily I rebooted to see if my gentoo-kernel was still working properly, but no, it could not load any modules at all, the same problem as I had with ck-sources in the beginning......

I want my modules to work using any of my installed kernels, internet has been proven useful in the emerge process....

so, any ideas, did you run into this problem first time you used multiple kernels?

maybe I am missing out on something obvious.

I feel I am a little unclear here, but I really do not know what to state further....

thanks in advance

----------

## smouge

Normally you should find your compiled modules in a directory

/lib/modules/2.4.20/kernel

for kernel 2.4.20

or 

/lib/modules/2.4.19/kernel

for kernel 2.4.19 etc.

Therefore look if you can find compiled modules in 

above directory.

----------

## Stieltje

nope, no drivers there, or any other place on my hdd except in my /lib/modules/2.4.20-ck6/kernel/drivers folder.

I tried to use copy my drivers into my /lib/modules/2.4.20-gentoo-r2/kernel/drivers folder and modprobe, does not work at all. all I get is the unresolved symbols error.

any other idea?

I have used multiple kernels before, but just the same kernel but with a different release #

but I cannot see why I cannot have a ck-kernel, a gentoo-kernel and a gaming-kernel with working modules installed on my system.....

well, I'll do it all over again :/ see if i stumble over something obvious.

/cheers

----------

## Stieltje

ok, I got the solution now.

when I run emerge, it erases the drivers in the other /lib/modules/ folders except for the one for the kernel in use..

the in my eyes uggly solution is to copy the folders with the old drivers, emerge whatever drivers, then copy the old drivers back again, ie saving them from deletion....

that whole system with the symlink thing should be disable-able, maybe it is...

but who many ppl use more than one kernel?

thanks anyway.

/cheers

----------

## lurid

Although it doesn't work with everything (ie. sometimes modules are required such as lm_sensors or certain video drivers) I generally suggest compiling everything you can into the kernel.  Once upon a time when computers didn't have gigs of RAM, small kernels were good to have.  Also once apon a time we used these silly things called floppy disks.  As neither of these are required anymore (assuming you have at least 128mb ram and can boot from a CD) having mini kernels really servers no purpose.

I like to think of it this way.  Lets say there is some catastrophic damage done to your root partition.  If everything your kernel needs to boot and possibly repair your data are modules, and thus destroyed with all the other data, how do you boot? By having your kernel completly (as much as possible) self contained and sitting on a seperate unmounted partition (as per Gentoo install instructions) you are pretty much safe in that once you have a working kernel, you'll always have a working kernel.

----------

## Stieltje

I only use a few modules, for my sound (alsa) and my internet (nvnet, did not see any support in the kernel last time I looked) and for nvidia drivers, ie things i cannot compile into my kernel. 

I can boot and have my system running, but without sound and without internet.

I do not argue that a system becomes less waterproof using modules, but I would really like to be able to emerge and compile as many kernels as I want without the extra trouble of copying around my module-drivers. Ok it takes me 20 more seconds, but anyway!

I hope that I help someone to a solution a little faster by spamming this thread  :Smile: 

/cheers

----------

## smouge

It should be no problem running different kernels on one system. I do that as well, 2.4.19, gentoo-sources and openmosix.

I did not know that an emerge will delete the modules of the other kernels, seems weird.

It doesn't look right to copy the modules from one kernel directory to another kernel directory. Better try to have the kernel compilation make the modules. are you sure you used the make modules etc stuff when compiling the kernel?

Anyhow, I always use above mentioned script which you can adapt for other kernels. It is an easy way to change to another kernel and have all the modules compiled, including the NVidia driver and to update lilo (if you use the lilo boot manager).

The only thing I have to compile manuallly when using another kernel is for example the driver fo my pcmcia wifi card. Maybe there are some other modules on your system as well that you have to recompile as well.

using kernel modules yes or no should make no difference in letting your system run. In the beginning I always compiled everything in the kernel, now I use modules as well. Sometimes I need to be able to load or unload a module.

----------

## OhSh33t

why are the initial "kernel conifg suggestions" within this FAQ almost the exact oppisite or whats posted here:

https://forums.gentoo.org/viewtopic.php?t=124530&highlight=

Just seemed strange that when researching on the Gentoo site that I would run into completetly oppisite suggested ways of compiling the Kernel. Not sure what is the right way to proceed now.

Thanks for any suggested clarification.

I'm running 2.4.20-gentoo-r7....and specifically referencing where this FAQ says:

 *Quote:*   

> 
> 
> -- under "File systems":
> 
>       -- select "Virtual memory file system support (former shm fs)"
> ...

 

and at the link above it's suggested that these are the required kernel parameters:

 *Quote:*   

> 
> 
> File systems > Psudo File Systems
> 
>  [*] /dev file system support (OBSOLETE)                       
> ...

 

Hope someone can clear this up for the noobians.

----------

## OhSh33t

I love it when I read the "README" file that accompanies linux pkgs.  But this might help others as well if they stumble into looking at this FAQ and the new Genkernel "genkernel-3.0.1" How-To.

Readme..... located at ... "/usr/share/genkernel"

 *Quote:*   

> 
> 
> IMPORTANT KERNEL NOTES:
> 
> - You MUST have devfs turned on at this time, but you MUST NOT
> ...

 

----------

## ScottTFrazer

Thanks in no small part to this thread and FAQ, I've managed to compile my first kernel from scratch (actually, I've done five now, each building on the last and adding or removing some little bit of functionality)

One thing I never saw mentioned explicitly was the possibility of using dmesg's output from the livecd as a way of determining what hardware is inside your computer (assuming you don't just know, of course  :Smile:  )

For me it helped determine the chipset of my IDE controller and soundcard on a machine that I had no clue what was inside.  Is there a downside to this?  Did I just get lucky?

----------

## OhSh33t

 *ScottTFrazer wrote:*   

> Thanks in no small part to this thread and FAQ, I've managed to compile my first kernel from scratch (actually, I've done five now, each building on the last and adding or removing some little bit of functionality)
> 
> One thing I never saw mentioned explicitly was the possibility of using dmesg's output from the livecd as a way of determining what hardware is inside your computer (assuming you don't just know, of course  )
> 
> For me it helped determine the chipset of my IDE controller and soundcard on a machine that I had no clue what was inside.  Is there a downside to this?  Did I just get lucky?

 

DMESG is great place to look but its like looking in a messy file cabinet.  Another thing to check after booting off a Gentoo boot cd is "lsmod". This will show you any modules that the boot cd loads if it is able to.

But I would have to say that the Grand Daddy of them all for me is "lspci" or  "lspci -v". This is apart of the "pciutils" pkg.  This gets all the info that I've ever needed. Example of the output on a PII 300..

```
toejam conf # lspci

0000:00:00.0 Host bridge: Intel Corp. 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 02)

0000:00:01.0 PCI bridge: Intel Corp. 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 02)

0000:00:07.0 ISA bridge: Intel Corp. 82371AB/EB/MB PIIX4 ISA (rev 02)

0000:00:07.1 IDE interface: Intel Corp. 82371AB/EB/MB PIIX4 IDE (rev 01)

0000:00:07.2 USB Controller: Intel Corp. 82371AB/EB/MB PIIX4 USB (rev 01)

0000:00:07.3 Bridge: Intel Corp. 82371AB/EB/MB PIIX4 ACPI (rev 02)

0000:00:0f.0 Ethernet controller: 3Com Corporation 3c905 100BaseTX [Boomerang]

0000:00:11.0 Multimedia audio controller: Ensoniq ES1371 [AudioPCI-97] (rev 02)

0000:01:00.0 VGA compatible controller: nVidia Corporation NV11 [GeForce2 MX/MX 400] (rev b2)

```

Same thing but with the "-vv" option.

```
toejam conf # lspci -vv

0000:00:00.0 Host bridge: Intel Corp. 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 02)

        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-

        Status: Cap+ 66Mhz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort+ >SERR- <PERR+

        Latency: 64

        Region 0: Memory at e8000000 (32-bit, prefetchable)

        Capabilities: [a0] AGP version 1.0

                Status: RQ=32 Iso- ArqSz=0 Cal=0 SBA+ ITACoh- GART64- HTrans- 64bit- FW- AGP3- Rate=x1,x2

                Command: RQ=1 ArqSz=0 Cal=0 SBA- AGP- GART64- 64bit- FW- Rate=<none>

0000:00:01.0 PCI bridge: Intel Corp. 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 02) (prog-if 00 [Normal decode])

        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B-

        Status: Cap- 66Mhz+ UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-

        Latency: 64

        Bus: primary=00, secondary=01, subordinate=01, sec-latency=64

        I/O behind bridge: 0000d000-0000dfff

        Memory behind bridge: ec000000-edffffff

        Prefetchable memory behind bridge: e0000000-e7ffffff

        Expansion ROM at 0000d000 [disabled] [size=4K]

        BridgeCtl: Parity- SERR- NoISA- VGA+ MAbort- >Reset- FastB2B+

0000:00:07.0 ISA bridge: Intel Corp. 82371AB/EB/MB PIIX4 ISA (rev 02)

        Control: I/O+ Mem+ BusMaster+ SpecCycle+ MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-

        Status: Cap- 66Mhz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-

        Latency: 0

0000:00:07.1 IDE interface: Intel Corp. 82371AB/EB/MB PIIX4 IDE (rev 01) (prog-if 80 [Master])

        Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-

        Status: Cap- 66Mhz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-

        Latency: 64

        Region 4: I/O ports at f000 [size=16]

0000:00:07.2 USB Controller: Intel Corp. 82371AB/EB/MB PIIX4 USB (rev 01) (prog-if 00 [UHCI])

        Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-

        Status: Cap- 66Mhz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-

        Latency: 64

        Interrupt: pin D routed to IRQ 10

        Region 4: I/O ports at e000 [size=32]

0000:00:07.3 Bridge: Intel Corp. 82371AB/EB/MB PIIX4 ACPI (rev 02)

        Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-

        Status: Cap- 66Mhz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-

        Interrupt: pin ? routed to IRQ 9

0000:00:0f.0 Ethernet controller: 3Com Corporation 3c905 100BaseTX [Boomerang]

        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-

        Status: Cap- 66Mhz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-

        Latency: 64 (750ns min, 2000ns max)

        Interrupt: pin A routed to IRQ 9

        Region 0: I/O ports at e400 [size=ee000000]

        Expansion ROM at 00010000 [disabled]

0000:00:11.0 Multimedia audio controller: Ensoniq ES1371 [AudioPCI-97] (rev 02)

        Subsystem: Ensoniq Creative Sound Blaster AudioPCI64V, AudioPCI128

        Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-

        Status: Cap+ 66Mhz- UDF- FastB2B- ParErr- DEVSEL=slow >TAbort- <TAbort- <MAbort- >SERR- <PERR-

        Latency: 64 (3000ns min, 32000ns max)

        Interrupt: pin A routed to IRQ 5

        Region 0: I/O ports at e800

        Capabilities: [dc] Power Management version 1

                Flags: PMEClk- DSI+ D1- D2+ AuxCurrent=0mA PME(D0+,D1-,D2+,D3hot+,D3cold-)

                Status: D0 PME-Enable- DSel=0 DScale=0 PME-

0000:01:00.0 VGA compatible controller: nVidia Corporation NV11 [GeForce2 MX/MX 400] (rev b2) (prog-if 00 [VGA])

        Subsystem: CardExpert Technology: Unknown device 0001

        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop+ ParErr- Stepping- SERR- FastB2B-

        Status: Cap+ 66Mhz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-

        Latency: 64 (1250ns min, 250ns max)

        Interrupt: pin A routed to IRQ 11

        Region 0: Memory at ec000000 (32-bit, non-prefetchable) [size=ed000000]

        Region 1: Memory at e0000000 (32-bit, prefetchable) [size=128M]

        Expansion ROM at 00010000 [disabled]

        Capabilities: [60] Power Management version 2

                Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)

                Status: D0 PME-Enable- DSel=0 DScale=0 PME-

        Capabilities: [44] AGP version 2.0

                Status: RQ=32 Iso- ArqSz=0 Cal=0 SBA- ITACoh- GART64- HTrans- 64bit- FW- AGP3- Rate=x1,x2,x4

                Command: RQ=1 ArqSz=0 Cal=0 SBA- AGP- GART64- 64bit- FW- Rate=<none>

```

Should be all you need.   Usually what I do when I first boot off a gentoo livecd is set the root passwd. I then immediately do "Alt-F2" and login to that terminal and do "lspci".  I then go back to "Alt-F1" and do the install get chrooted in and when it comes to compiling the Kernel manually you can switch from your "menuconfig kernel screen" to the other Terminal with the needed lspci output. 

If you don't set the root passwd before chrooting in then you will not beable to login into the extra Terminals available via "Alt-F1-4". You can try but you'll be prompted to login..  well you can't really login without a passwd set.  :Very Happy: 

Well you could always "emerge pciutils" when chrooted in and that would dl and compile the needed pkg too run "lspci"... 

Hope that helps. Helped me tremendously. Have fun. Manually compiliation is the only way to go. I would also make sure that when your inside "make menuconfig" to SELECT the HELP link and read through each item even if it doesn't make sense. This helped me to take all the mystery out of compiling manually.  

Funny thing is I can't find a doc on howto specifically UPGRADE. I've found some doc's but they seem to be missing steps which is pretty scarry. And I haven't found any for the 2.6 kernel, like switching from 2.6.8 to like 2.6.8-r3 for a specific source.

----------

## ScottTFrazer

sweet.  That's much nicer  :Smile: 

----------

## griffinme

Two of the three resource links at the end of the article appear to be dead.

----------

## Double Click

Any suggestion on how to deal with remote (through SSH/Putty) compiles? In other words if the new kernel does not work it will default back to a specified working kernel without requiring a manual/physical reboot or intervention?

----------

## nader emami

[quote="smouge"]Nice tips,

I would add to these tips that it is very handy when you have a working kernel, to save the new kernels you make with a different name and to adapt lilo in such a way can boot from both kernels.

For example, my lilo looks like this:

```
# $Header: /home/cvsroot/gentoo-x86/sys-apps/lilo/files/lilo.conf,v 1.3 2002/09/30 00:55:18 woodchip Exp $

# Author: Ultanium

# Start LILO global section

menu-scheme=Wb

boot = /dev/hda

prompt

map = /boot/System.map

lba32

timeout=150

delay = 50

default = GentooNew

vga = normal   # Normal VGA console

# End LILO global section

# Linux bootable partition config begins

   image = /boot/bzImage

   root = /dev/hda3

   #root = /devices/discs/disc0/part3

   label = Gentoo2420

   read-only # read-only for checking

   append = "hdd=ide-scsi"

# Linux bootable partition config ends

# Linux bootable partition config begins

   image = /boot/bzImageOpenMosix

   root = /dev/hda3

   label = GentooOpenMosix

   read-only # read-only for checking

   append = "hdd=ide-scsi"

# Linux bootable partition config ends

# Linux bootable partition config begins

   image = /boot/bzImageNew

   root = /dev/hda3

   label = GentooNew

   read-only # read-only for checking

   append = "hdd=ide-scsi"

# Linux bootable partition config ends

```

and I have made a small script: /usr/src/makekernel

```
#!/bin/bash

usage() {

cat << FOO

usage: makekernel 2.4.19

       makekernel 2.4.20

       makekernel 2.4.20-openmosix

note:

examples:

      

FOO

   exit 1

}

kernel2419() {

   rm -f /usr/src/linux

   ln -s /usr/src/linux-2.4.19 /usr/src/linux

   cd /usr/src/linux 

   #rm -Rf /lib/modules/2.4.19/kernel/*

   cp .config /boot/.config

   make mrproper 

   cp /boot/.config .config 

   make menuconfig 

   make dep && make clean bzImage modules modules_install 

   cp /boot/bzImageNew /boot/bzImageNew.old 

   cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImageNew

   cp .config /boot/.config_2.4.19

   emerge unmerge nvidia-glx

   emerge unmerge nvidia-kernel

   emerge nvidia-glx

   emerge nvidia-kernel

   lilo -v

   exit 1

}

kernel2420() {

   rm -f /usr/src/linux

   ln -s /usr/src/linux-2.4.20 /usr/src/linux

   cd /usr/src/linux 

   #rm -Rf /lib/modules/2.4.20/kernel/*

   cp .config /boot/.config

   make mrproper 

   cp /boot/.config .config 

   make menuconfig 

   make dep && make clean bzImage modules modules_install 

   cp /boot/bzImageNew /boot/bzImageNew.old 

   cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImageNew

   cp .config /boot/.config_2.4.20

   emerge unmerge nvidia-glx

   emerge unmerge nvidia-kernel

   emerge nvidia-glx

   emerge nvidia-kernel

   lilo -v

   exit 1

}

kernel2420openmosix() {

   rm -f /usr/src/linux

   ln -s /usr/src/linux-2.4.20-openmosix-r2 /usr/src/linux

   cd /usr/src/linux 

   #rm -Rf /lib/modules/2.4.20/kernel/*

   cp .config /boot/.config

   make mrproper 

   cp /boot/.config .config 

   make menuconfig 

   make dep && make clean bzImage modules modules_install 

   cp /boot/bzImageNew /boot/bzImageNew.old 

   cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImageNew

   cp .config /boot/.config_2.4.20

   emerge unmerge nvidia-glx

   emerge unmerge nvidia-kernel

   emerge nvidia-glx

   emerge nvidia-kernel

   lilo -v

   exit 1

}

# Main program loop starting here

if [ `id -u` -ne 0 ]

then

   eerror "${0}: must be root."

   exit 1

fi

if [ $# -lt 1 ]

then

   usage

fi

if [ "$1" = "2.4.19" ] ; then

   kernel2419

elif [ "$1" = "2.4.20" ]; then

   kernel2420

elif [ "$1" = "2.4.20-openmosix" ]; then

   kernel2420openmosix

fi

```

In this way I can quickly make a new kernel. Each compiled kernel is saved as /boot/bzImageNew

If the new kernel doesn't run, I can still start the system with the older 2.4.19 or 2.4.20, gentoo-sources, openmosix  etc. kernel.

I hope you find this usefull.

I am a new user of Gentoo. I have installed it after some tryings on my laptop (toshiba A110-225), naturally with networkless option.

Because of Ethernet card of this machine. So I have to compile the kernel with the appropriate card driver for the Ethernet card. 

I have read some material and I have to have gentoo-source at the next directory /usr/src/linux. But this directory is empty and I 

don't know where I can find the source of the kernel. Would you like to tell me how I can solve this problem? 

Maybe here is not the place in which i can ask my question. My apologize for this.

With regards,

----------

## truc

```
   emerge unmerge nvidia-glx

   emerge unmerge nvidia-kernel

   emerge nvidia-glx

   emerge nvidia-kernel 
```

be aware that now, you should have nvidia-drivers installed instead (or the legacy one)

----------

## golding

I would like to pare my kernel and modules down to just those needed for this machine. 

How would I go about finding exactly what has been loaded so I can answer [N] to all other options in .config?

Is it just a matter of looking at dmesg and lsmod?

----------

## d2_racing

Great post  :Smile: 

A newbie will know how to debug his kernel with a backup kernel in case that something goes wrong...kernel panic  :Smile: 

----------

## wynn

d2_racing: Thanks â though most of the credit should go to wilburpan as the ideas come from KC11.

If you can spare the time, please keep an eye on it as it evolves. Your comments and corrections are appreciated.

----------

## rodia

Hello Wynn

Thanks for the link. This is a very full and good tut.

Although I don't use :

```
make defconfig
```

To generate a default config file for my new kernels

I'd rather copy an old and working config file of a previous kernel version

and run make menuconfig , exit and save to perform the adequate

patches.

It prevents from reconfiguring all the options again.

Whats your point of view about this ?

Thanks again,

Red1

----------

## wynn

Yes, I'd copied the .config from the previous kernel version and used it as the base of the new one with "make oldconfig" for quite some time but recently this failed to work or work properly. For instance, I upgraded from 2.6.18 to 2.6.19 here â carefully adding the SATA drivers, testing the experimental PATA drivers and going back to "old PATA" when they didn't work â but burning CDs was very slow with the minimum buffer fill going down to 7% when it was a minimum of 77% before.

I eventually found out that the DMA on the CD burner hadn't been enabled.

Based on that, I think reconfiguring the kernel starting from "make defconfig" may well take less time, all in all, than just running "make oldconfig" on the old one.

That's why I've written it as it is but, of course, everybody will have their own opinion â these Forums are proof of that, if any was needed   :Very Happy: 

----------

## d2_racing

I use make oldconfig when I change of kernel release only.

Exemple : 2.6.19-Gentoo-r2 --> 2.6.19-Gentoo-r5.

----------

## Earthwings

Updated the old FAQ and merged the comments to the new one to this thread.

----------

## slycordinator

Most of that script isn't needed.

If I do "make install" after "make modules_install" it will copy the kernel to /boot. It'll also make symlinks called /boot/vmlinuz and /boot/vmlinuz.old

/boot/vmlinuz will now point to the kernel you just installed. And if you already had a /boot/vmlinuz previously, vmlinuz.old will now point to that kernel old kernel.

And the nvidia-kernel and glx steps aren't needed because this means you'd have to do that for each kernel modules. Instead you do:

(before running the script) do "emerge module-rebuild"

Then in the script do "module-rebuild rebuild"

----------

## d2_racing

I will translate this thread for the French Forum. Is there any objections before I start ?

----------

## d2_racing

I have just translated this howto in French here : https://forums.gentoo.org/viewtopic-t-555623.html

----------

## Southernman

To Wynn and all other contributors of this FAQ! *bows to the gods*

Thank you! I'll be giving this another shot in the next couple of days.

The tips and tricks you showed us will definately help out! 

Although... I don't recall who said it, someone made mention with 

machine specs being what they are today, having a lean, 

mean kernel build isn't as important as what it used to be.

Being a nOOb at kernel configuring.. it's something I aim to do regardless!

PS. The flash at the end of the FAQ was pretty cool.

Kinda fast for us old farts though...  :Wink: 

----------

## d2_racing

Yeah, this flash thing is pretty impressive  :Smile: 

----------

## jseymour

Just a quick note, the Kernel configuration slideshow has moved to a different url. You can find it at this URL:

http://tutorialmasters.com/node/3

Sorry for anyone who may have missed it, but moved my site to drupal so the address had to change.

Update: Fixed with a 301 redirect/  :Smile: 

----------

## nikolavp1

Here is something i use for my kernel updates... 

```
#!/bin/bash

LOADER_ROOT_PARTITION="hd0,6"

KERNEL_PARAMETERS="root=/dev/hda7 vga=0x315 quiet"

if [[ -d /usr/src/linux ]];then

        echo "Cleaning the old sources"

else

        echo "You don't have a symbolic link or a directory /usr/src/linux and the script depends on that"

        exit 3

fi

#Get the VERSION from the symbolic link

VERSION=$(readlink /usr/src/linux)

#Entering the sources dir

cd /usr/src/linux

make mrproper

if [[ -f /proc/config.gz ]];then

        zcat /proc/config.gz > ./.config

else

        "There isn't /proc/config.gz and the script depend on it"

        eixt 3

fi

#If you want to edit the old options, comment "make oldconfig" and uncomment "make menuconfig"

###############################################################################

#make menuconfig

make oldconfig

make -j2

make modules_install

mv /usr/src/linux/arch/i386/boot/bzImage /boot/"${VERSION%/}"

#Making the menu.lst configuration; some versions of grub have grub.conf instead so you can change it if

#there isn't a symbolic link(there should be).

#TODO: Make a sed hack that edit the default parameter and put the new section as default

#section_number=$(grep title /boot/grub/menu.lst | wc -l)

echo "" >> /boot/grub/menu.lst

echo "title=${VERSION%/}" >> /boot/grub/menu.lst

echo "root(${LOADER_ROOT_PARTITION})" >> /boot/grub/menu.lst

echo "kernel /boot/${VERSION%/} ${KERNEL_PARAMETERS}" >> /boot/grub/menu.lst
```

If a sed master can make the sed command for the section_number implementation i would be glad to see it  :Smile: 

P.S. This is for Grub ^_^

----------

## d2_racing

Why do you use this command ? : 

```
make -j2 
```

If you have MAKEOPTS= '-j2' in your /etc/make.conf, you don't have to pass this variable to make.

----------

## nikolavp1

 *d2_racing wrote:*   

> Why do you use this command ? : 
> 
> ```
> make -j2 
> ```
> ...

 Actually you have to  :Wink:  /etc/make.conf is only "sourced" by portage, as far as i know.

----------

## techprophet

Just a tip: make sure you build your hard drive driver into the kernel as well as the driver for your motherboard's SATA/PATA/ATA driver. It cause me lots of headaches trying to figure out what was wrong before seeing that.

----------

## aramis_qc

This is a great how-to for a beginner. Thank's to d2_racing who dropped me an e-mail to tell me about its existence. 

As I'm rewriting French installation documentation on Gentoo-Québec web site (from PDF to Mediawiki format), this wynn's how-to will greatly help me. Most of all, my approach is quite similar to the one of this tutorial. Can you read French ? So just look at this wiki still in the work :

http://gentoo-quebec.org/wiki/index.php/100-Installation:Gentoo_classique_unstable#Configuration_du_noyau

I have a question somehow. The how-to shows how to use udevinfo. It seems that udevinfo and other commands such like undevmonitor and the likes are now replaced by udevadm. Is it possible that someone updates the tutorial in order to tell about the usage of udevadm ?

----------

## sconte

Please capitalize "i" of "bzimage" in

 *Quote:*   

> 
> 
> Codice:
> 
> cp -pv arch/i386/boot/bzimage /boot/kernel-2.6.19-gentoo-r5
> ...

 

Hi, s.

----------

## Thistled

 *Quote:*   

> To find the chipset driver (or drivers) for /dev/sda, runCode:
> 
> udevinfo -a -p /sys/block/sda | grep DRIVERS

 

Sorry, this command does not work.

```
# udevinfo -a -p /sys/block/sdb | grep DRIVERS

-su: udevinfo: command not found

# 
```

Am I doing something wrong, or is it time to update this helpful guide?

----------

## ppurka

Most udev commands have moved to udevadm. So, now you should run

```
udevadm info ...
```

----------

