# more than one kernel image: what happens with modules?

## Vizcacha

I've searched in the faq and only found a thread explaining this using bash scripts but i want to do it all manually.

These are the steps i'd take:

1) make && make modules_install

2) cp arch/i386/boot/bzImage /boot/kernel_new

3)cp System.map /boot/System.map-kernel_new   #is this necessary?

4)cp .configure /boot/kernel_new-configure

5)Write /etc/fstab with the correct information

6) # Here is where I stop, where do i write the modules i want automatically loaded at startup if i want to keep the information in /etc/modules.autoload.d/kernel-2.6 so that i can use my old kernel image? Can i modprobe modules compiled in another kernel image?

Another thing: aren't the modules of my old kernel image affected when i recompile the new kernel.. i mean are they uninstalled?

Am i missing something here?  :Confused: 

----------

## Wedge_

When you run "make modules_install", what it does is copy the modules for the kernel in question to the directory /lib/modules/<kernel version>. This means that modules for different kernel versions don't interfere with each other, since they get placed in distinct directories. They aren't uninstalled when you compile a new kernel. 

If you want to load modules at startup, you can just use /etc/modules.autoload.d/kernel-2.6 for all 2.6 kernels (it's read whenever you boot a 2.6 kernel, so it isn't restricted to one kernel version). As long as you're using the same modules in each kernel, it won't need updating at all. 

You may be able to force modules compiled for another kernel to load, but it's not a good idea and is likely to cause problems.

----------

## dpshak

A disclaimer, as I'm a NOOB too - YMMV!  I don't understand what you would change in /etc/fstab (step 5) when you upgrade the kernel - unless you're going from 2.4 to 2.6.  If that's the case, best to read the Handbook.  If you're going from 2.6.11 to 2.6.12(for instance) I don't believe you would change anything in /etc/fstab.  Maybe you meant to make changes in your boot-loader instead(/boot/grub/grub.conf?)?  There you would want to ADD new lines (I learned this the hard way) to allow booting the new kernel.  This way if you messed up on the kernel configuration, you can always reboot into your old kernel and start over again.  As for #3, when I updated from 2.6.12-r4 to 2.6.12-r6, I didn't copy the System.map over and so far so good... 

As far as the modules are concerned, Wedge_ covered that far better than I could!

----------

## Wedge_

 *dpshak wrote:*   

> A disclaimer, as I'm a NOOB too - YMMV! I don't understand what you would change in /etc/fstab (step 5) when you upgrade the kernel - unless you're going from 2.4 to 2.6. If that's the case, best to read the Handbook. If you're going from 2.6.11 to 2.6.12(for instance) I don't believe you would change anything in /etc/fstab. Maybe you meant to make changes in your boot-loader instead(/boot/grub/grub.conf?)? There you would want to ADD new lines (I learned this the hard way) to allow booting the new kernel. This way if you messed up on the kernel configuration, you can always reboot into your old kernel and start over again. As for #3, when I updated from 2.6.12-r4 to 2.6.12-r6, I didn't copy the System.map over and so far so good... 

 

You're right about /etc/fstab, there won't normally be any need to change it for a kernel upgrade, unless you had enabled a new filesystem driver or something. I don't think copying System.map is necessary, although it may be useful for some applications.

----------

## NeddySeagoon

Vizcacha,

Provided your new kernel has a new version everything is kept seperate for you except the name of the kernel file in /boot. Thats up to you at the time of the copy anyway.

If you want an experiemental compile of your existing kernel tree you must change the kernel name.

The name is kept at the top of /usr/src/linux/Makefile here V

```
ERSION = 2

PATCHLEVEL = 6

SUBLEVEL = 11

EXTRAVERSION = -gentoo-r4
```

Its traditional to change the EXTRAVERSION like

```
EXTRAVERSION = -gentoo-r4-mykernel
```

. It will now be treated as a new kernel.

Look here http://62.3.120.141/Gentoo for an example of what to do with /boot and grub.conf.

Thats a live running gentoo system. You can browse a lot of it.

----------

## Vizcacha

Wow thanks a lot guys, your answers are really helpful.

Yeah i'm experimenting with my existing kernel 2.6.12-gentoo-r4

So in conclusion:

1)I change the EXTRAVERSION in the Make file to gentoo-r4-mykernel

2)I compile the new kernel 

3) About the modules is it ok if i make a file called "/etc/modules.aoutoload.d/kernel-2.6_mykernel" and rename it to kernel-2.6 whenever i want to use my new kernel image? 

I mean:

mv /etc/modules.autoload.d/kernel-2.6  /etc/modules.autoload.d/kernel-2.6_old

mv /etc/modules.autoload.d/kernel-2.6_new /etc/modules.autoload.d/kernel-2.6

So that i have the correct information corresponding the modules i want loaded at startup. Some way to automate this?

----------

## NeddySeagoon

Vizcacha,

You can change the EXTRAVERSION to anything you like. The modules know what they are called from the version magic.

Use, modinfo <module_name> to see its version magic. I have 

```
vermagic:       2.6.12-gentoo-r4 preempt K7 REGPARM 4KSTACKS gcc-3.4
```

in my running kernel.

The kernel make modules_install will make the correct /lib/modules/`uname -r`/mod.... directory.

When you load a module, the version magic is checked. If it doesn't match, its not loaded. So don't be renaming things.

When you boot your old kernel, it will use its own modules, when you boot your new kernel, it will use its own modules.

You don't have to do anything special to keep them apart. The kernels can recognise their own modules.

----------

## Vizcacha

There is something i don't understand.

This is my /etc/modules.autoload.d/kernel-2.6 file:

```
#vmmon

#vmnet

nls_ascii

libcrc32c

#ipt_NOTRACK

#iptable_raw

oprofile

snd-ac97-codec

snd-via82xx

snd-mixer-oss

snd-pcm-oss

snd-seq-midi

snd-seq-midi-event

snd-seq

snd-seq-device

snd-page-alloc

snd-rawmidi

snd-timer

snd

snd-pcm

snd-mpu401-uart

soundcore

#shaper

s2io

dummy

#cytherm

#phidgetservo

#usbhid

#touchkitusb

#usb-storage

ac

thermal

processor

button

fan

video

firmware_class

#hw_random

sata_sis

sata_sx4

ide-scsi

ipr

#dpt_i2o

as-iosched

cfq-iosched

#pktcdvd

deadline-iosched

parport_pc

parport_serial

parport

```

When compiling my new kernel i'm going to use some of those modules and some others. Do i just place the new ones in between those ones ? (what if they are repeated?)

I mean, can a module have 2 or more Version Magic?

Thanks for the patience  :Embarassed: 

----------

## NeddySeagoon

Vizcacha,

The names in /etc/modules.autoload.d/kernel-2.6 are fed to modprobe.

There is nothing in that file that ties it to a specific kernel version (otherthan the 2.6 part).

modprobe finds out from the kernel where to fetch the moduled from and from the /etc/modules.autoload.d/kernel-2.6

what modules to load.

Add more modules to the file as required but duplicates are not required.

Be prepared for error messages (which you can ignore) when you try to load a module that the kernel version you are starting does not have. Thats normal.

----------

## Vizcacha

Thank you. This's the answer i was waiting, i think i'm going to try and compile it tonight

----------

## Vizcacha

It didn't work  :Confused:  . The directory /lib/modules/kernel-2.6-gentoo-r4-EXPERIMENTAL was never created (gentoo-r4-EXPERIMENTAL is the EXTRAVERSION of the new kernel)

The thing it installed everything in /lib/modules/kernel-2.6.12-gentoo-r4 and loads of things failed when i tried to boot from whichever of both images.

Should i have created the directory in /lib/modules

When i typed "modinfo $MODULE" i expected a vermagic with *EXPERIMENTAL (of course having chosen a module belonging to this image)

----------

## NeddySeagoon

Vizcacha,

Post the first half a dozen lines of Makefile from your experimental kernel tree.

----------

## Vizcacha

```
VERSION = 2

PATCHLEVEL = 6

SUBLEVEL = 12

EXTRAVERSION = -gentoo-r4-EXPERIMENTAL

NAME=Woozy Numbat

```

----------

## NeddySeagoon

Vizcacha,

Your Makefile edit is OK.

Boot both kernels and test each with 

```
uname -a
```

Choose a module that is present in both kernels and check its version magic.

When you do modinfo, it only looks at modules beloning to the running kernel.

I warned you about the errors you should expect with either kernel. Only you know what modules exist for each kernel,

you can judge if the errors are to be expected or not.

----------

## Vizcacha

I think i might have made a mistaken when choosing which things to include or not in my kernel because the kind of errors wheren't like modules failing, they seemed more important errors, it didn't even enter the runlevels. 

Thanks for the help, if i manage to do it right i'll follow your advice

----------

