How do I load additional kernel modules during installation?

Asked by David Ward

When booting an Ubuntu installation CD, what steps are needed to load a kernel module that was not included in the installer?

Specifically:

I am installing the server edition of Ubuntu Hardy 8.04.2. For networking, I have a USB cable modem, and USB cable modems require the 'cdc_ether' kernel module. This module is part of the standard Ubuntu kernel (under 'drivers/net/usb'), but it was not included in the installer and so the network can not be found or used during installation.

Under the 'pool' directory there are packages for version 2.6.24-23.46 of the kernel. I can extract the kernel module 'cdc_ether.ko' from this package and copy it to a USB flash drive. Then when the installer loads, I can switch to a shell, mount the USB flash drive, copy the kernel module into the appropriate directory in '/lib/modules', and run 'depmod'.

However, when I try 'modprobe cdc_ether', I receive a 'Invalid module format' error. If I run 'dmesg', I see the error when trying to load the kernel module: 'disagrees about version of symbol struct_module'.

I assume that the installer's kernel is the same as the main Ubuntu kernel, just excluding some of the modules? What steps am I missing or what am I doing wrong?

I looked through the livecd-tools scripts to try to get an understanding of how the kernel is packaged into the installer, but I didn't get anywhere.

Even if it's not necessary to have networking working during the installation to successfully install in my case, I'd still like to know what the correct way is to handle this, because this could happen for more important modules too.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
actionparsnip
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

You will need to compile the module with the kernel source of the version on the install CD. If you need it in the liveCD you can install the package that contains the module, you can use apt-file for this

sudo apt-get install apt-file; sudo apt-file update; apt-file search cdc_ether.ko

you could even remaster then install CD to have this module by default on the liveCD (can take a while to do but worth it if you need it)

I think I covered all bases..

Revision history for this message
David Ward (dpward) said :
#2

Is the same kernel used by the live CD environment and the stand-alone installer? i.e., do I need to boot into a Live CD environment (using the desktop edition CD), compile the linux-image package from source, copy /lib/modules/.../cdc_ether.ko to a USB flash drive, then reboot into the server installer and load the module as I was trying to do before?

The module I am trying to use is not part of a separate package; it is included in the linux-image package, but was left out of the initramfs on the CD.

Is my procedure for inserting the module into the installer's kernel after it boots otherwise correct (without remastering the CD)?

Revision history for this message
Best actionparsnip (andrew-woodhead666) said :
#3

sure you can remove or add modules as you need. Its the nature of a modular kernel.

you could compile the module from the server boot but you will need to specify the source directory for the desired kernel source if its different to the booted kernel.

You need to have the module for the modem that is compiled for the running kernel's source. So however you achieve that is your call dude.

Revision history for this message
David Ward (dpward) said :
#4

Thanks. Here's some notes on what I did for future reference.

# 1. Install prerequisite packages.
sudo apt-get install build-essential dh-make kernel-wedge fakeroot

# 2a. Download the sources for the installer kernel.
apt-get source linux=2.6.24-23.46

# 2b. Obtain the sources manually if the previous command doesn't work.
wget https://launchpad.net/ubuntu/hardy/+source/linux/2.6.24-23.46/+files/linux_2.6.24.orig.tar.gz
wget https://launchpad.net/ubuntu/hardy/+source/linux/2.6.24-23.46/+files/linux_2.6.24-23.46.diff.gz
wget https://launchpad.net/ubuntu/hardy/+source/linux/2.6.24-23.46/+files/linux_2.6.24-23.46.dsc
dpkg-source -x linux_2.6.24-23.46.dsc

# 3. Enter the sources directory.
cd linux-2.6.24

# 4. Add the 'cdc_ether' module into the build process for the
# 'nic-usb-modules' package.
echo "cdc_ether ?" >> debian/d-i/modules/nic-usb-modules

# 5. Build the packages.
fakeroot debian/rules binary-udebs flavours=generic custom_flavours=

At this point I manually copied the 'cdc_ether.ko' and 'rndis_host.ko' files from the 'debian/build/build-generic/drivers/net/usb' directory to a USB flash drive. After booting the installer, at the language configuration screen, I pressed Ctrl+Alt+F2 to access a shell. Then I mounted the USB flash drive, copied the modules into '/lib/modules/2.6.24-23-generic/kernel/drivers/net/usb', unmounted the USB flash drive, and pressed Ctrl+Alt+F1 to return to the installation.

Perhaps a better way (if I had been patient and let the kernel compilation complete) would have been to copy the resulting 'nic-usb-modules-2.6.24-23-generic-di.udeb' file to the USB flash drive, instead of the individual kernel module files. Then at the shell I could have run:

anna-install nic-usb-modules-2.6.24-23-generic-di.udeb

to extract the kernel modules in the appropriate directory.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#5

Awesome dude. Good work :)

BTW, you will need to compile the module if you upgrade your kernel so keep the source handy.