Realtek 8168 module issue

My cute little dual-core atom system (D945GCLF2) had a small hiccup with Debian. The kernel kept loading on boot the r8169 (incorrect) module for the onboard network device, which caused all sorts of weird phenomenon including, but not limited to, strange tasting coffee, distracted cats, ifconfig showing seemingly random numbers for dropped frames every time and not obtaining IP from DHCP servers occasionally.

The high-level solution is to replace the incorrect module with the appropriate one. Here goes:

  • Obtain the correct module (r8168)

Go to Realtek website and download the source for the latest driver.

Extract the archive:

tar -jxf r8168-x.y.z.tar.bz2

Prepare build environment:

apt-get install build-essential linux-headers-`uname -r`

Compile the driver source:

cd r8168-x.y.z
make clean modules && make install
  • Replace using the correct module

Before moving on, take note that removing the module for networking will disable the network interface. Which means any remote session running on the interface will be terminated.

Unload the current (incorrect) module:

rmmod r8169

Generate module dependency:

depmod

Load the correct module:

modprobe r8168

Update existing initramfs:

update-initramfs -u

If the kernel insists on loading the r8169 module, add the line blacklist r8169 into /etc/modprobe.d/blacklist:

echo blacklist r8169 >> /etc/modprobe.d/blacklist

(edited 18-07-2012, thanks to x in comments)
or, for newer distros:

echo blacklist r8169 >> /etc/modprobe.d/blacklist.conf

Hopefully all is good after going through the troubles.

p/s: My r8168.ko (Compiled for Lenny, 2.6.26-2-686) can be found under Resources.