Log in

No account? Create an account
27 March 2012 @ 01:09 am
using modprobe for module substitution with fallback  
Realtek drivers on linux boxes are not perfect - were leading servers to occasional hangs, especially when working in gigabit network. Hetzner's has special Wiki page for it - "The Linux r8169 driver for the Realtek network chips does not always work correctly, even in the newest kernel versions." . So, I was forced to build module from Realtek's sources and load it before/instead of r8169. That shouldn't be hard, even that wiki article has all needed steps. But article suggests to disable r8169 module via blacklisting, but I wanted to provide fallback mode - i.e. imagine you installed new kernel/upgraded old one and server be booted without network as custom module is not compiled for it and new one is blacklisted.
So, I've googled around and found that modprobe.conf(5) with help of modprobe(8), can be set to execute particular command on module load request (install). 
coolcold@server1:~$ cat /etc/modprobe.d/forceinstall.conf
#using forced install for module override:
install r8169 /sbin/modprobe r8168 || /sbin/modprobe -v -i r8169

This conf line tells modprobe what to do on request of loading module r8169 - it will try to load r8168 module, if this fails, tries to load 8169 modules with "-i" switch, which instructs modprobe to ignore install sections within this invocation (so it won't cycle). Therefore, even if module r8168 is missing in system, 8169 will be loaded, and there is not need for blacklisting!

P.S. Hint - don't forget to update-initramfs after editing modprobe related configs.