How does updating the kernel affect custom modules?

5,028

This really depends on how this module was installed. The mechanism of DKMS is specifically created for automatic recompiling against the new kernel installed.

Plain kernel modules are only built for very version they were compiled for and keep working when updates do not break the ABI. However, the Ubuntu updates appear to break the ABI quite frequently and require kernel modules to be recompiled. As this is a very much boring and repetitive task, DKMS was invented to overcome this. It inserts hooks in APT to trigger compiling and installing the new version.

To view the current kernel modules installed using DKMS (example):

dkms status
nvidiabl, 0.79, 3.5.0-22-generic, x86_64: installed
nvidiabl, 0.79, 3.7.5-030705-generic, x86_64: installed
nvidia-current, 313.09, 3.5.0-22-generic, x86_64: installed
nvidia-current, 313.09, 3.7.5-030705-generic, x86_64: installed
vboxhost, 4.2.6, 3.5.0-22-generic, x86_64: installed
vboxhost, 4.2.6, 3.7.5-030705-generic, x86_64: installed

Here you can see I have installed some kernel modules into DKMS, only the nvidiabl one myself, the others were installed by the Nvidia driver package and Virtualbox package.

The modules are located (installed) in a specific directory for each kernel version:

/lib/modules/
├── 3.5.0-22-generic
│   ├── build -> /usr/src/linux-headers-3.5.0-22-generic
│   ├── initrd
│   ├── kernel
│   │   ├── arch
│   │   ├── crypto
│   │   ├── drivers
│   │   ├── fs
│   │   ├── lib
│   │   ├── net
│   │   ├── sound
│   │   └── ubuntu
│   └── updates
│       └── dkms
└── 3.7.5-030705-generic
    ├── build -> /usr/src/linux-headers-3.7.5-030705-generic
    ├── initrd
    ├── kernel
    │   ├── arch
    │   ├── crypto
    │   ├── drivers
    │   ├── fs
    │   ├── lib
    │   ├── mm
    │   ├── net
    │   └── sound
    └── updates
        └── dkms

In order to get a custom kernel module with no support provided for DKMS, it needs some "packaging" you'll have to do yourself, of you'll have to recompile it yourself everytime. In other words, a "typical" ./configure; make; sudo make install will just install one specific kernel module and requires you to recompile it every time.

If you fail to do so, the kernel module will simply not be found after an update. It will not look in the old directory and if you would force to load it, it would fail to insert probably. In case the installation overwrote a system default one, it might also load the non-custom one.

I'm not going to include the DKMS packaging here, as I think I've answered your question by now.

Share:
5,028

Related videos on Youtube

Caustic
Author by

Caustic

Updated on September 18, 2022

Comments

  • Caustic
    Caustic over 1 year

    I am curious as to what happens when you run

    sudo apt-get update && sudo apt-get upgrade
    

    if you have custom kernel modules installed.

    Are there hooks to reinstall your custom module? Are the modules completely unaffected by the upgrade?

    I ask this because every time I do an upgrade I'm worried that the modules I've installed from source are going to break. At this moment I haven't had any issues yet, but I'd like to find out more regarding what happens to modules when you do update your kernel via regular updates.

  • guntbert
    guntbert over 11 years
    Great explanation - you might want to correct the sentence "The modules are installed in a specific.." though.
  • Caustic
    Caustic over 11 years
    Excellent! Thank you for such a detailed answer. So typically if you install from source, it's not going to be included in the kernel update? e.g. configure && make && make install