# Building separate kernel

## pengie

Hello all,

I just finish installing Gentoo 2004.3 on my laptop(toshiba te 2300).  What I want to do next is to Compile another Kernel base from 2.6.11 currently I'm running on 2.4 kernel.

CAn some point me to an already existing thread or right links to do this. What they got in the docs link in gentoo is for upgrade only not creating a separate one.

please help.

----------

## adaptr

What do you mean by "creating a separate kernel" ?

As long as the kernel version is different a new kernel will always be built - neither the kernel image nor the modules will be overwritten.

3rd party modules like nvidia will be more tricky - they will need to be rebuilt when you want to actually use another kernel.

----------

## pengie

Ok Sorry for not elaborating properly. I just finished installing gentoo with 2.4 kernel. I just downloaded kernel 2.6.11 and want to use that as my kernel but want to retain the current 2.4 kernel just incase I made a mistake. 

I think this is more clearer

----------

## adaptr

You don't need to do anything; emerge the new kernel, change the symlink, and build it.

When you install it in /boot, give it a distinctive name and add it as an entry to your boot loader config.

That's it, really.

----------

## pengie

 *adaptr wrote:*   

> You don't need to do anything; emerge the new kernel, change the symlink, and build it.
> 
> When you install it in /boot, give it a distinctive name and add it as an entry to your boot loader config.
> 
> That's it, really.

 

Sorry adaptr I'm new in this game so let's break the process down.

 *Quote:*   

> emerge the new kernel

  does this mean i'm going to 

```
emerge kernel
```

 *Quote:*   

> change the symlink, and built it

  How do I do this:?: 

 *Quote:*   

> install it in /boot

  does this mean copying the bzImage and others

and last I know those one.

----------

## syg00

Grab um trusty Handbook, and have a look at "Installing the Sources" - section 7.c in my tattered old-ish one.

Not bad when one section can answer *all* your questions    :Shocked: 

----------

## pengie

 *syg00 wrote:*   

> Grab um trusty Handbook, and have a look at "Installing the Sources" - section 7.c in my tattered old-ish one.
> 
> Not bad when one section can answer *all* your questions   

 

Ok I've got my handbook, but it starts with

```

cd /usr/src/linux

make menuconfig

```

The question is how do I emerged the new kernel that I downloaded,?

----------

## syg00

Damn, don't you hate that - back up one section.

Sorry.

EDIT: What do you mean - emerge does the download for you. Where/how did you "download" the sources ??.

----------

## pengie

What directory should I be putting my downloaded kernel 2.6.11 before I do an emerge gentoo-sources.

By the way i'm doing this one networkless. Can't access my network card or wireless card yet.

----------

## adaptr

All source packages go in /usr/portage/distfiles.

If you are copying it off the CD, just copy it there, then

```
emerge gentoo-dev-sources

cd /usr/src/linux

make menuconfig
```

Make absolutely, positively sure you do not sync the tree!

(In your case you can't, since you have no network, but even so...)

How did you download 35MB of kernel sources when you don't have a network ?

Oddball.

----------

## syg00

 *adaptr wrote:*   

> Oddball.

 

Don't take that as personal pengie    :Twisted Evil: 

I read it as "Odd" (as in the situation), *NOT* "Oddball" as in *you*...     :Smile: 

----------

## pengie

Do I have to put dev in this command

 *adaptr wrote:*   

> 
> 
> ```
> emerge gentoo-dev-sources
> 
> ...

 

That's okay I got another computer which got internet acces to download missing stuff. Last time someone else install gentoo on this laptop we can't manage to make the modem work. and now I'm having with my e100.

----------

## syg00

Yes gentoo-dev-sources is probably the one to go for - there is a web page somewhere that describes them in addition to the handbook.

Must admit I have never tried Gentoo with the winmodem used on most laptops - the LAN should work out of the box though. I did  fight briefly with a winmodem on my Toshiba Satellite Pro under RH9, but gave updefeated.

At the time the chip used was too new, and the developers hadn't got it included.

Went with wifi, and never looked back.

----------

## Sith_Happens

If you are changing kernel sources, be sure to either change the /usr/src/linux symlink manually, or emerge the sources with the symlink useflag set, i.e.:

```
USE="symlink" emerge gentoo-dev-sources
```

----------

## pengie

 *Sith_Happens wrote:*   

> If you are changing kernel sources, be sure to either change the /usr/src/linux symlink manually, or emerge the sources with the symlink useflag set, i.e.:
> 
> ```
> USE="symlink" emerge gentoo-dev-sources
> ```
> ...

 

Now I'm getting a bit confuse. What should be the first step I be doing: I'll repeat the question from start again.

I have downloaded the kernel 2.6.1 and copy it on a cd.

Now should I be copying it to a directory(/usr/portage/distfiles) or should I be doing something else?

after copying emerge gentoo-dev-sources?

then cd /usr/src/linux or other directory?

then make menu config?

then make dep?

then cp all neccessary files?

```
USE="symlink" emerge gentoo-dev-sources
```

 at what stage do I do this?

----------

## Sith_Happens

 *Quote:*   

> Now should I be copying it to a directory(/usr/portage/distfiles) or should I be doing something else?
> 
> after copying emerge gentoo-dev-sources?
> 
> then cd /usr/src/linux or other directory?
> ...

 If you already have the sources in /usr/src change the /usr/src/linux symlink to point to the new kernel source directory.  Then run make menuconfig to configure the kernel, make && make modules_install to compile the kernel bzImage and modules, then cp the bzImage and System.map to the boot partition.

----------

## pengie

 *Sith_Happens wrote:*   

> If you already have the sources in /usr/src change the /usr/src/linux symlink to point to the new kernel source directory.  Then run make menuconfig to configure the kernel, make && make modules_install to compile the kernel bzImage and modules, then cp the bzImage and System.map to the boot partition.

 

I got the sources still on a directory in my windows.  Where do I need to copy the files and what should I do next after copying it to that directory.

 *Quote:*   

> 
> 
> should I be copying it to a directory(/usr/portage/distfiles) or should I be doing something else? 
> 
> and after copying emerge gentoo-dev-sources? 

 

----------

## Sith_Happens

Where did you get the sources from?  If you have a single *.tar.bz2 file for the kernel sources then just untar the file to /usr/src, then make it so the /usr/src/linux symlink points to the directory:

```
rm /usr/src/linux

cd /usr/src

ln -s <name_of_source_dir> linux
```

----------

## pengie

Should I be doing this:

```
#tar -xvjf linux-2.6.11.4.tar.bz /usr/src/
```

----------

## Sith_Happens

Add the -p flag for perserve permissions.  It probably doesn't matter, but just do it anyway, humor me.  :Wink:  

```
tar -xvjpf linux-2.6.11.4.tar.bz /usr/src/
```

----------

## pengie

After I did an emerge gentoo-dev-sources, how do my system know that I'm making a 2.6 kernel?

----------

## pengie

After I did an emerge gentoo-dev-sources, how do my system know that I'm making a 2.6 kernel?

----------

## adaptr

By changing the linux symlink:

```
rm -f /usr/src/linux

ln -sf /usr/src/linux-2.6.whatever /usr/src/linux

```

----------

## pengie

After I save the kernel that I build I execute this command:

```
(For 2.6 kernel)

# make && make modules_install

```

Did I do it right? If I did what is the next step in replace to this line?

```
Code Listing 14: Installing the kernel

 

# cp arch/i386/boot/bzImage /boot/kernel-2.4.26-gentoo-r9

# cp System.map /boot/System.map-2.4.26-gentoo-r9

 

Code Listing 15: Backing up your kernel configuration

 

# cp .config /boot/config-2.4.26-gentoo-r9

 

```

Also most of the thing that I'm not sure that I need to include I made them as a module instead of built-in, is that alright?

----------

## adaptr

Actually, that is the kernel build command.

To install it to your boot directory the easiest way - by a huge margin - is to use

```
mount /boot

make install
```

and modify your bootloader config to point to vmlinuz as the kernel.

Make install will update that symlink for every kernel you install, and keep a second symlink, vmlinuz.old, that points to the previous kernel so you can always boot that too (if you set it up in your bootloader).

No kernels are deleted when using make install; they are all given their proper names, and configs and system maps are copied as well.

Using modules is indeed the best way until you know exactly which drivers and features you need (or if you just don't care).

----------

## pengie

 *adaptr wrote:*   

> Actually, that is the kernel build command.
> 
> To install it to your boot directory the easiest way - by a huge margin - is to use
> 
> ```
> ...

 

Do I still need to mount /boot, I dont have a /boot partition that's the first question.

when you say  *Quote:*   

> modify your bootloader config to point to vmlinuz as the kernel

 , how?(I might know this but just to stupid to realise) that is the secon question.

----------

## pengie

Sorry guys but I kinda stuck on this part can anyone help?

 *pengie wrote:*   

>  *adaptr wrote:*   Actually, that is the kernel build command.
> 
> To install it to your boot directory the easiest way - by a huge margin - is to use
> 
> ```
> ...

 

----------

## syg00

People are (and generally do) answering presuming you're following the handbook.

If not, you need to think about what's being suggested, and modify for your situation. Actually we all need to do that regardless.

Work in reverse.

You said you had a working 2.4 system. Check the grub.conf to see;

a) where (what directory) that is loaded from

b) what your current kernel naming convention is.

Put the new kernel/config/system.map in there using similar naming convention. If it's using vmlinuz, use a different name. Personally I don't like to rename the current entry. I like to leave things alone, and use a new name, along the lines of the handbook. Just update kernel-2.6.9-r3 (or whatever the current/doco says) to what you have  just compiled; kernel-2.6.11-r4 or whatever.  There are benefits in using that naming structure in a multi-kernel environment.

Add that as a new entry to grub.conf using the current entry (and maybe the handbook) as a guide.

That way you can always re-boot the old system if/when it all goes to hell.

----------

## adaptr

Yes, and that's what makes this whole process a lot more complicated - I can't even fully follow you and I've compiled a zillion kernels.

My advice is to stick with the kernel default make install procedure; check it out for a few kernels and you'll see that it works very well for all sorts of situations, as it will never delete or rename kernels - it only changes symlinks.

----------

