2011-08-22

Permanently fixing Realtek networking on Ubuntu Natty

So here we are again. Kernel upgrade, then reboot => no network. Last week a kernel upgrade borked my network again, and it took a while before I remembered that I needed the r8168 module (see last posting).

Today it happened again. So I think to myself "There must be a better way."  It turns out there is:  It is called DKMS, the "Dynamic Kernel Module Support".  Essentially it works by registering the module for rebuild whenever the kernel is upgraded.


Here's what I did:
  1. Copy the source code to /usr/src/r8168-8.023.00 - the directory name must be MODULE-VERSION
  2. Create a dkms.conf:
    PACKAGE_NAME="r8168"
    PACKAGE_VERSION="8.023.00"
    AUTOINSTALL="yes"
    
    MAKE[0]="'make' modules"
    BUILT_MODULE_NAME[0]="r8168"
    BUILT_MODULE_LOCATION[0]="src"
    DEST_MODULE_LOCATION[0]="/kernel/drivers/net"
    

  3. Tell DKMS about the module: sudo dkms add -m r8168 -v 8.023.00
  4. Build it: sudo dkms build -m r8168 -v 8.023.00
  5. And finally install it: sudo dkms install -m r8168 -v 8.023.00
  6. At this point, you can use DKMS to build a deb package if you wish.  In any case, further kernel upgrades will magically build and install the module.
Update 2012-01-30: As pointed out by Ben Tebulin in a comment, the make command needs an extra level of quotes; see this Debian bugreport.

3 comments:

Ben Tebulin said...

Oh THANK YOU, man! I was aware that DKMS is able to solve these "break things after kernel update" easily, but I was always missing such a short guide on how to setup and register a new DKMS module.

On Ubuntu 11.10 (oneiric) I needed to quote the "make" word additionally with in your dkms conf: There is a bug in dkms which silently adds a KERNELRELEASE parameter thus breaking the dkms build.

In this case dkms build reports:
make KERNELRELEASE=3.0.0-16-generic modules....(bad exit status: 2)

In this case change the dkms.conf. The changed line should read as follows:

MAKE[0]="'make' modules"

Refer to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=553625

Again many thanks!

Espen Wiborg said...

Well, dang! That would explain why my DKMS build didn't work last time. :) I've updated the post; thanks for the the tip!

Racko said...
This comment has been removed by the author.