Hetzner - DokuWiki

Installation des r8168-Treibers/en

The Linux r8169 driver for the Realtek network chips does not always work correctly, even in the newest kernel versions. There can be timeouts and/or frequent link up/link down state changes. Even system crashes may occur.

One solution is to use the official Realtek r8168 driver. Unfortunately this driver is not included in any distribution. For CentOS it can be installed from 3rd party repositories. For Debian, Ubuntu and most other distributions it must be compiled by the user.

This article describes how to setup the network driver.

Inhaltsverzeichnis

Installing kmod-r8168 from elrepo.org

ELRepo is an RPM repository for Enterprise Linux packages. ELRepo supports Red Hat Enterprise Linux and its derivatives (CentOS, Scientific Linux and others). It is the easiest way to get the r8168 driver for the standard upstream kernels.

NOTE: If you are using a special kernel like Virtuozzo, OpenVZ or something similar you MUST compile the module yourself!

Import the public key:

rpm --import http://elrepo.org/RPM-GPG-KEY-elrepo.org

Install ELRepo for RHEL 6, CentOS 6 or SL 6:

rpm -Uvh http://elrepo.org/elrepo-release-6-4.el6.elrepo.noarch.rpm

Install the kmod-r8168 Realtek r8168 driver:

yum --enablerepo=elrepo install kmod-r8168

After a reboot of the server the new driver will be used. It stays active even after kernel upgrades.

Installing r8168-kmp from the OpenSUSE NIC drivers repo

OpenSUSE offers pre-built kernel module packages (kmp). You just have to add the repository to zypper and install the matching package. In the following example OpenSUSE with the default kernel is used.

cd /etc/zypp/repos.d
wget http://download.opensuse.org/repositories/drivers:/nic/openSUSE_Tumbleweed/drivers:nic.repo
zypper refresh
zypper install r8168-kmp-default

Before rebooting, the r8169 driver must be blocked from loading.

echo "blacklist r8169" >> /etc/modprobe.d/99-local.conf

After the reboot only the r8168 module should be active and show up in 'lsmod'.

Installation from source

Prerequisites

Please make sure you are running the latest kernel available by running yum or apt-get and then rebooting.

CentOS

On CentOS the header packages of the kernel, 'kernel-devel' and 'kernel-headers', as well as the compiler, will need to be installed to replace the driver:

yum install gcc gcc-c++ kernel-devel kernel-headers

Debian/Ubuntu

In Debian/Ubuntu the name of the header package depends on the selected kernel. It can be for example 'linux-headers-generic' or 'linux-headers-server'. All the other required packages will be installed via build-essentials:

aptitude install build-essential linux-headers-`uname -r`

Proxmox

In Proxmox the headers can be found in the pve-headers package

aptitude install pve-headers-`uname -r`

Getting the sources

cd /tmp
wget http://mirror.hetzner.de/tools/Realtek/drivers/r8168-8.039.00.tar.bz2
tar xjf r8168-8.039.00.tar.bz2

Compiling the driver

The package contains an autorun.sh script that automatically compiles the drivers and replaces the present r8169 driver. Doing so means the network connection is lost. You should therefore start this script in a screen session and only use it if you are absolutely sure that the kernel module can be compiled without errors. You can check this beforehand through "make modules".

cd r8168-8.039.00
make modules
# or
make all

If there are no errors with "make modules", you can replace the driver in the current system. In this case the network connection is interrupted and the r8169 driver permanently disabled!

screen
cd r8168-8.039.00
./autorun.sh

If you do not want an interruption of the system or you want to only temporarily disable the r8169 driver, you can instead compile the driver as shown below.

Activating the new driver

CentOS

In the file /etc/modprobe.conf the appropriate driver for eth0 needs to be edited. To do this the line

alias eth0 r8169

must be changed to

alias eth0 r8168

The new driver must now be activated. To do this a simple shell script can be created that does the necessary steps.

echo "rmmod r8169" > /tmp/r8168
echo "depmod -a" >> /tmp/r8168
echo "modprobe r8168" >> /tmp/r8168
echo "service network restart" >> /tmp/r8168
echo "service ipaliases restart" >> /tmp/r8168

Execute that script:

sh /tmp/r8168

After several seconds the server should be back online using the new network driver. The working directory can now be removed:

rm -rf /root/r8168

Debian/Ubuntu

After installing the driver, update the module dependencies.

depmod -a

First the r8169 network driver needs to be blocked, so as to prevent the kernel from loading it. Note: If additional NICs are installed in the server, the driver must not be blocked.

Ubuntu/Debian 6.0 (Squeeze):

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

Next, the kernel must be forced to include the driver in the initrd. This also ensures that if additional NICs have been installed the new r8168 module is loaded before the r8169 module.

echo "r8168" >> /etc/initramfs-tools/modules

Afterwards the initrd will be rebuilt.

update-initramfs -v -t -u

Now you can reboot the server.

After a kernel update the driver might need to be recompiled.



© 2017. Hetzner Online GmbH. Alle Rechte vorbehalten.