How to make Realtek R8168 drivers stick

My build has a Realtek network card for which by default the R8169 driver is installed. This driver has serious performance problems, which can be solved by changing to the official Realtek R8168 driver. On several forums you can find how-to’s that I have adopted for Rockstor as per below. This works fine until I reboot my system after which the R8169 driver are active again instead. Does anyone know how to get the updated drivers to stick after a reboot?

The procedure I used :

1 Install development environment

# sudo yum install --enablerepo=rockstor gcc gcc-c++ kernel-ml kernel-ml-headers kernel-ml-development

2 Download and compile Realtek drivers from Realtek website:
http://211.75.126.106/downloads/downloadsView.aspx?Langid=1&PNid=13&PFid=5&Level=5&Conn=4&DownTypeID=3&GetDown=false
Select the Linux driver for kernel up to 4.15. Use a normal web browser to do this, as there is download protection (captcha)

Now copy/sftp the file to /opt/0012-r8168-8.046.00.tar.bz2

# cd /opt
# tar xf 0012-r8168-8.046.00.tar.bz2
# cd r8168-8.046.00
# sudo make modules

If this is successful, you can compile and replace the current drivers

# screen
# cd /opt/r8168-8.046.00
# sudo ./autorun.sh

_Note that your network connection will be shortly interrupted, as the old driver r8169 driver will be removed_

3 Check the driver is now installed

    # ethtool -i enp2s0
driver: r8168
version: 8.046.00-NAPI
firmware-version:
expansion-rom-version:
bus-info: 0000:02:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no

Hi @Jaco1960,

I just looked at the autorun.sh and from what I can see is it renames the old driver to r8168.bak. So, the proper driver should be getting loaded on reboot.

If your kernel gets updated, you will potentially need to re-compile the driver and reinstall it. I’m wondering if you did the driver compile and install while there was a reboot needed to be performed on your Rockstor server after a kernel update had been done. If so, the newest kernel installed wouldn’t have been active.

Hi @vesper1978,

No joy :confused: There is 1 kernel active (4.12.4-1.el7.elrepo.x86_64) and I repeated the procedure after reboot to make sure this is indeed the one loaded. I can see the r8169.ko is renamed to r8169.bak and find this output with lsmod:

# lsmod grep "Module\|r8"
Module                  Size  Used by
r8168                 548864  0
r8169                  81920  0
mii                    16384  1 r8169

Hi @Jaco1960,

One thing you can try to do is to blacklist the r8169 driver.

Add

blacklist r8169
install r8169 /bin/true

To /etc/modprobe.d/blacklist.conf

Then reboot.

That should prevent the r8169 driver from being loaded.

Hi @vesper1978

Solved it :smiley: . Thanks for the tips. As it turns out there is no need to blacklist the r8169 driver. The problem was in the final part of the .autorun.sh where the ramdisk is rebuild. The script cannot deal with CentOS kernel > 4. The solution is to include as a last step a rebuild of the ramdisk with “dracut -f” as described here: https://www.thegeekdiary.com/centos-rhel-6-how-to-rebuild-initial-ramdisk-image/