# Compile and use multiple kernels

## HydroDiOxide

Hi there,

I've installed gentoo 2007.0 on my toshiba satellite 1800-400 laptop. I've used the genkernel option (described in the gentoo handbook) to compile my kernel. The system is up and running (needs some tweaking, ofcourse) and seems to work fine. Sound wasn't working, though, and I used the ASLA guide to get it up and running, which seems to work fine (although the device doesn't show up in the system>preferences>sounds menu in gnome).

The guide let me compile (see the ALSA guide) a new kernel which seems to have overwritten my previous kernel. That's okeh because it works. However, I was wondering how I can configure/compile another kernel (just to learn how to do this (read n00b)) and use it next to my current kernel. So I want to make another kernel, add it to grub so I can choose which kernel to use, so I can enhance my knowledge of kernel configuring and compiling.

Is this possible?

----------

## d2_racing

Of course, you can read this howto for that : https://forums.gentoo.org/viewtopic-t-539024.html

----------

## HydroDiOxide

Thanks for that. I'll be sure to read it.

----------

## HydroDiOxide

I've read through the HOWTO and also this HOWTO on a different subject, but which deals with multiple kernels as well. Some questions remain, however.

What does the symbolic link do? The HOWTO's point out that it has to point to the kernel of my choice, but don't I choose the kernel of my choice in GRUB?

When running 

```
make menuconfig 
```

 or 

```
genkernel --menuconfig
```

 what is created? Is it a bzImage? If yes, how is it called and where is stored? I need to copy it to /boot to make it bootable?

The kernel in use is stored in /boot, right? Can I just rename it even though it is in use?

Quite some questions. I hope you're willing to answer.

----------

## d2_racing

 *HydroDiOxide wrote:*   

> 
> 
> What does the symbolic link do?
> 
> 

 

The symbolic link is there for your Kernel, in fact, when you compile a kernel, you need to update this link /usr/src/linux, because with that you can compile a kernel the kernel that you want.

----------

## d2_racing

 *HydroDiOxide wrote:*   

> 
> 
> The HOWTO's point out that it has to point to the kernel of my choice, but don't I choose the kernel of my choice in GRUB?
> 
> 

 

After you have compile you kernel that you have choose with /usr/src/linux and with the command make && make modules_install, the result of your kernel will be a bzImage that can be found here : /usr/src/linux/arch/i386/boot/bzImage

After that you need to create your bzImage and place it inside your /boot partition with that command :

cp arch/i386/boot/bzImage /boot/kernel-version

exemple :

cp arch/i386/boot/bzImage /boot/kernel-2.6.20-Gentoo-r8

----------

## d2_racing

 *HydroDiOxide wrote:*   

> 
> 
> When running 
> 
> ```
> ...

 

Make menuconfig is when you choose to configure manually your kernel and Genkernel is use when you want a generique Kernel.

After theses commands, you will have the result kernel inside the bzImage that can be found here : 

/usr/src/linux/arch/i386/boot/

And yes, you need to copy /usr/src/linux/arch/i386/boot/bzImage to /boot and also change de name to have a more explicit name for your kernel.

----------

## HydroDiOxide

How can I check what my current kernel is supporting (eg iso mounting, what kind of cpu's, what chipset, that kind of stuff)?

----------

## mark_alec

 *HydroDiOxide wrote:*   

> How can I check what my current kernel is supporting (eg iso mounting, what kind of cpu's, what chipset, that kind of stuff)?

 Assuming you built in config.gz support, `zcat /proc/config.gz` will show you what your kernel supports.

----------

## d2_racing

first, to check your kernel version, just type this :

```

# uname -a

```

----------

## Rabbi Hillel

I always use it like this:

For fresh sources:

```
genkernel --menuconfig  --gensplash=livecd-2006.1 --gensplash-res=1024x768 --bootloader=grub --debuglevel=2 all
```

And if I change something in already compiled sources I use:

```
genkernel --menuconfig --gensplash=livecd-2006.1 --gensplash-res=1024x768 --bootloader=grub --debuglevel=2 --no-clean --no-mrproper all
```

For the bootsplash you'll need to do this first:

```
emerge -va splashutils splash-themes-gentoo splash-themes-livecd
```

You can also do

```
genkernel  --gensplash=livecd-2006.1 --gensplash-res=1024x768 --bootloader=grub
```

and (after long time of compiling (1 1/2 hours on my ancient pIII 1Ghz)) you'll have a livecd-alike kernel.

The 

```
--bootloader=grub
```

 option does the job for making the new kernel appearing in grub on boot.

References:

http://www.gentoo.org/doc/en/genkernel.xml

http://gentoo-wiki.com/HOWTO_fbsplash

----------

## HydroDiOxide

@d2_racing

I've read through the HOWTO and it makes sense to me. I understand the process much better now. However, the article mentions something about not configuring and compiling a new kernel as root. However, I can neither save the configuration file nor compile a kernel as my normal user.

Also, I have saved a configuration file (as root) under another name than .config in /usr/src/linux and I want to use that config file as the source for the kernel compilation. Is that possible?

Another question remains. How do I know what to compile as a module and what not? I will probably have some other questions later on... sorry about that.

----------

## d2_racing

 *HydroDiOxide wrote:*   

> @d2_racing
> 
> I've read through the HOWTO and it makes sense to me. I understand the process much better now. However, the article mentions something about not configuring and compiling a new kernel as root. However, I can neither save the configuration file nor compile a kernel as my normal user.
> 
> 

 

I know, this howto is from a book, so since Gentoo has Portage, I think that we are save with that  :Smile: 

 *HydroDiOxide wrote:*   

> 
> 
> Also, I have saved a configuration file (as root) under another name than .config in /usr/src/linux and I want to use that config file as the source for the kernel compilation. Is that possible?
> 
> 

 

No, just copy your config file in /boot like that :

```

# cd /usr/src/linux

# cp .config  /boot/config-kernel-2.6.20-r8

```

With than, when you can to recompile or upgrade your kernel, with the following :

```

# cp /boot/config-kernel-2.6.20-r8 /usr/src/linux/.config

```

Another question remains. How do I know what to compile as a module and what not? I will probably have some other questions later on... sorry about that.

----------

## d2_racing

[quote="HydroDiOxideAnother question remains. How do I know what to compile as a module and what not? I will probably have some other questions later on... sorry about that.[/quote]

When you will get some kernel panics or some error when loading your box  :Smile: 

----------

## HydroDiOxide

@d2_racing

So the rule of thumb is... compile everything as modules, except for the obvious. So what are the obvious? Proc, File system, ide driver... any more?

----------

## d2_racing

 *HydroDiOxide wrote:*   

> @d2_racing
> 
> So the rule of thumb is... compile everything as modules, except for the obvious. So what are the obvious? Proc, File system, ide driver... any more?

 

Ok... I will recap the howto : Always configure in hard [*] all your hardware :

- Video card

- Chipset for the board

- File System

- IDE driver

- SATA drive

- Network card

And just for the record check my kernel configuration : http://www.gentoo-quebec.org/doc/hb_part1_chap1.html#doc_chap7

----------

## HydroDiOxide

@d2_racing: Hey, thanks for the recap.. can't recall reading that in this https://forums.gentoo.org/viewtopic-t-539024.html HOWTO, however.

About the link: wish my french was what is used to be... is it available in english as well?

Do you have answer for my configure/compile as a user question as well, maybe?

Cheers!

----------

## d2_racing

 *HydroDiOxide wrote:*   

> About the link: wish my french was what is used to be... is it available in english as well? Cheers!

 

No, only in French, since I'm french Canadien  :Smile: 

----------

## dspahn

When I compile a kernel, I keep the core system built in, and not load it as modules. This includes any boot-level resources, filesystems needed. sound cards, network cards, and encryptions/protocols needed to support them. I build things that I might need to unload, such as experimental hardware, as modules. I try to minimize the modules I use and keep it all built in. this makes the kernel move slower and use more memory, but it seems to make my overall system run smoother and better. I also enable module autoloading to cut back on how much configuration my modules need. Having an intimate understanding of the system's hardware (start with lspci) will help you decide what to leave out.

----------

## d2_racing

 *dspahn wrote:*   

> When I compile a kernel, I keep the core system built in, and not load it as modules. This includes any boot-level resources, filesystems needed. sound cards, network cards, and encryptions/protocols needed to support them. I build things that I might need to unload, such as experimental hardware, as modules. I try to minimize the modules I use and keep it all built in. this makes the kernel move slower and use more memory, but it seems to make my overall system run smoother and better. I also enable module autoloading to cut back on how much configuration my modules need. Having an intimate understanding of the system's hardware (start with lspci) will help you decide what to leave out.

 

It's so true  :Smile: 

----------

## HydroDiOxide

Thanks for all the help on that.

This is the error which I get when I try to run make in the /usr/src/linux folder as a normal user

```
HOSTCC  scripts/basic/fixdep

scripts/basic/fixdep.c:397: fatal error: opening dependency file scripts/basic/.fixdep.d: Permission denied

compilation terminated.

make[2]: *** [scripts/basic/fixdep] Error 1

make[1]: *** [scripts_basic] Error 2

make: *** No rule to make target `include/config/auto.conf', needed by `include/config/kernel.release'.  Stop.
```

When I try to save a .config in that directory as a user I get an error like permission denied.

Thanks.

----------

## d2_racing

Of course  :Smile: 

You need to use your root account to do that  :Smile: 

----------

## HydroDiOxide

Okeh, so this advice

 *Quote:*   

> Important Warning: The kernel developers advise against uncompressing the kernel source code, configuring or building the kernel as root. It should be done as an ordinary user. Only the one or two commands needed to install the kernel and the modules should be run as root. There have been bugs in the build process in the past which have caused files in /dev to be deleted when run as root and uncompressing the kernel archive as root can lead to some files getting the wrong permissions. gkh-lkn: "None of the primary kernel developers build kernels as root".

 

in this HOWTO is not possible? And I can only configure, compile and install a new kernel as root?

----------

## d2_racing

Yes, but in other distribution, maybe you can do the manipulation of the kernel with a fakeroot method.

But in Gentoo, we compile as root  :Smile: 

----------

## HydroDiOxide

Right, I managed to compile my own booting kernel. However, I get some errors during the boot process. I wasn't able to write them all down (can you pause the boot process to write those errors down?).

Most of them concern things like snd_timer, ac97_bus and the general warning is: Fatal error ... invalid module format (with a path in the error as well).

Also I get the warning that DMA is not enabled. I have compiled it in the kernel, though, as described in the gentoo handbook.

Any ideas?

----------

## d2_racing

 *HydroDiOxide wrote:*   

> Right, I managed to compile my own booting kernel. However, I get some errors during the boot process. I wasn't able to write them all down (can you pause the boot process to write those errors down?).
> 
> 

 

I don't know  :Sad: 

 *HydroDiOxide wrote:*   

> 
> 
> Most of them concern things like snd_timer, ac97_bus and the general warning is: Fatal error ... invalid module format (with a path in the error as well).
> 
> 

 

Are you using the alsa inside the kernel or the package from gentoo ?

 *HydroDiOxide wrote:*   

> 
> 
> Also I get the warning that DMA is not enabled. I have compiled it in the kernel, though, as described in the gentoo handbook.
> 
> 

 

Can you post

```

# hdparm -tT /dev/hdaà

```

----------

