Realtek RTL8111 alternate driver (r8168) in Unraid 4.7


Recommended Posts

Hello everyone,

 

I've been having some  network problem here and there with my Unraid server ever since day 1 I've built it.

Nothing serious but quote annoying, when the network is very busy and at high load, sometimes I'd get a "network name unavailable" error on Windows in the middle of a file operation (either read or write). At first I thought it was my networking setup or maybe just a quirk in Unraid's code.

 

But a while ago, I accidentally read several of lines like this in the middle of the syslog :

Apr  7 10:33:03 zxunraid kernel: r8169: eth0: link up

Apr  7 10:33:34 zxunraid last message repeated 36 times

Apr  7 10:34:38 zxunraid last message repeated 22 times

Apr  7 10:34:47 zxunraid last message repeated 9 times

 

The mainboard I'm using is MSI H55MA-E43 with the onboard PCI Express LAN 10/100/1000 Fast Ethernet by Realtek 8111E Ethernet Controller.

Paired it with an i3-550, great motherboard (microATX, total 8 SATA ports onboard, USB3) but kinda lousy onboard Ethernet

 

I got curious and googled around for a little bit. Then I found out about the Realtek driver issues, how Unraid 4.7 is using the stock r8169 driver, and the possible fix by using r8168 driver.

 

It seems that the driver is mostly fixed in unraid 5 beta, but since I don't like to use a beta in my production box, it's not a good answer for my problem.

 

So I googled around and found several threads that said using Realtek's r8168 driver helped them solve the issues. Unfortunately since Unraid is somehow a barebone Slackware, compiling it inside unraid is not a straightforward copy & paste from those threads.

 

After several sleepless nights, I finally managed to compile the driver, I tested it for a couple of weeks and it seems there's no more of those errors in my syslog again even in high network load (many parallel read/write operation on the network)

 

Here's how I did it, I hope it can help others who might be in a similar position as I was.

If you have a similar problem and you're using the same network chipset (Realtek RTL8111) then you might want to give this a try

 

PS: I'm mostly from Windows world and a Linux noob, so please correct me for any mistakes.

 

 

First thing's first

Check if you're really using the r8169 driver with this command

lsmod | grep r8169

If it comes out blank, you're not using r8169, not much use in reading the rest of the post if you're not using it :)

 

Compile your own driver / long version : (TL;DR version below)

To compile the driver, you will need to install the compiler packages and also the kernel headers. The easiest method to gain both is to use gfjardim's excellent script to compile VirtualBox for Unraid (wiki page)

 

You can download these packages yourself or you can let gfjardim's script do it automatically if your Unraid box is connected to the internet.

 

Here are the links :

http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.9.tar.gz

http://slackware.oregonstate.edu/slackware-12.2/slackware/d/gcc-4.2.4-i486-1.tgz

http://slackware.oregonstate.edu/slackware-12.2/slackware/l/glibc-2.7-i486-17.tgz

http://slackware.oregonstate.edu/slackware-12.2/slackware/d/binutils-2.18.50.0.9-i486-1.tgz

http://slackware.oregonstate.edu/slackware-12.2/slackware/d/make-3.81-i486-1.tgz

http://slackware.oregonstate.edu/slackware-12.2/slackware/a/cxxlibs-6.0.9-i486-1.tgz

http://slackware.osuosl.org/slackware-12.2/slackware/a/pkgtools-12.1.0-noarch-7.tgz

http://slackware.osuosl.org/slackware-12.2/slackware/d/perl-5.10.0-i486-1.tgz

http://slackware.osuosl.org/slackware-12.2/slackware/a/cpio-2.5-i486-3.tgz

http://slackware.osuosl.org/slackware-12.2/slackware/a/patch-2.5.4-i486-1.tgz

http://slackware.osuosl.org/slackware-12.2/slackware/l/ncurses-5.6-i486-3.tgz

 

And the download page for the actual Realtek r8168 driver :  Get the Linux driver for kernel 2.6.x (version 8.029.00)

 

And the Linux make header script : makeheader.sh

 

Put the Realtek driver & makeheader.sh in a directory (I use /mnt/disk1/workdir), and the tgz files inside packages subdir (/mnt/disk1/workdir/packages)

Start by extracting the driver and running the script:

cd /mnt/disk1/workdir
tar xvf r8168-8.029.00.tar.bz2
chmod +x makeheader.sh
makeheader.sh

 

If everything is properly set up, it should need about 5-10 minutes to compile the kernel headers.

 

If you try to compile the driver now, you will find that the compiler couldn't find some 'build' and 'source' files, turns out stock Unraid links those to the wrong location

unraid47dev:/mnt/disk1/workdir$ ll /lib/modules/2.6.32.9-unRAID/

total 284

drwxr-xr-x 4 root root    0 2011-01-25 07:21 ./

drwxr-xr-x 3 root root    0 2011-01-25 07:21 ../

lrwxrwxrwx 1 root root    23 2011-01-25 07:21 build -> /usr/src/linux-2.6.32.9

<snip>

lrwxrwxrwx 1 root root    23 2011-01-25 07:21 source -> /usr/src/linux-2.6.32.9

 

Fix the 'build' and 'source' links to the new header :

rm /lib/modules/2.6.32.9-unRAID/build && ln -s /usr/src/linux /lib/modules/2.6.32.9-unRAID/build 
rm /lib/modules/2.6.32.9-unRAID/source && ln -s /usr/src/linux /lib/modules/2.6.32.9-unRAID/source

 

There is a bug in Realtek's source code which prevents you from compiling it, spits out this error message

/mnt/disk1/workdir/r8168-8.029.00/src/rtltool.c: In function 'rtltool_ioctl':

/mnt/disk1/workdir/r8168-8.029.00/src/rtltool.c:177: error: implicit declaration of function 'capable'

/mnt/disk1/workdir/r8168-8.029.00/src/rtltool.c:177: error: 'CAP_NET_ADMIN' undeclared (first use in this function)

/mnt/disk1/workdir/r8168-8.029.00/src/rtltool.c:177: error: (Each undeclared identifier is reported only once

/mnt/disk1/workdir/r8168-8.029.00/src/rtltool.c:177: error: for each function it appears in.)

 

This one is the real killer, I spent a whole night looking for the answer. Turns out we need to insert a line "#include <linux/capability.h>" to the top of the "/mnt/disk1/workdir/r8168-8.029.00/src/rtltool.c" file

Let's fix it :

sed -i '1i #include <linux/capability.h>' /mnt/disk1/workdir/r8168-8.029.00/src/rtltool.c

 

Afterwards, the file rtltool.c should read like this :

#include <linux/capability.h>

#include <linux/module.h>

#include <linux/version.h>

#include <linux/pci.h>

#include <linux/netdevice.h>

#include <linux/delay.h>

#include <linux/in.h>

#include <linux/ethtool.h>

#include "r8168.h"

#include "rtl_eeprom.h"

#include "rtltool.h"

... <snip>

 

 

Finally we can compile the driver itself

cd r8168-8.029.00 && make all && cd ..

 

And get the compiled driver from the src subdir

mv /mnt/disk1/workdir/r8168-8.029.00/src/r8168.ko /mnt/disk1/workdir

 

Tada, you got your compiled driver (r8168.ko)

unraid47dev:/mnt/disk1/workdir$ ll /mnt/disk1/workdir

total 333

drwx--x--x 5 root root    224 2012-04-13 20:31 ./

drwx------ 7 root root    168 2012-04-13 18:38 ../

drwxr-xr-x 3 root root    80 2012-04-13 19:34 headers/

-rwx------ 1 root root  2313 2012-04-13 20:14 makeheader.sh*

drwxr-xr-x 2 root root    504 2012-04-13 19:45 packages/

drwx--x--x 3 root root    176 2012-04-13 20:29 r8168-8.029.00/

-rwx------ 1 root root  63166 2012-04-13 22:15 r8168-8.029.00.tar.bz2*

-rw-r--r-- 1 root root 267757 2012-04-13 20:31 r8168.ko

 

Time to put the driver to use.

Copy the r8168.ko driver to your Unraid flashdisk (I use /packagescustom)

[ ! -d /boot/packagescustom ] && mkdir /boot/packagescustom
cp /mnt/disk1/workdir/r8168.ko /boot/packagescustom

 

Copy these line to your go script (change as necessary to reflect where you put the driver)

# Replace Realtek r8169 driver to r8168
cd /lib/modules/2.6.32.9-unRAID/kernel/drivers/net
rmmod r8169
mv r8169.ko r8169.ko.bak
cp /boot/packagescustom/r8168.ko .
depmod -a
insmod r8168.ko

 

Restart and then check if Unraid loads the new driver correctly

ls mod | grep r8168

 

And that's it folks!

 

 

TL;DR version :

Disclaimer : I have no idea if my pre-compiled driver will work or not on your machine. I'm not familiar with Linux's driver rules. But I did compile the driver on stock Unraid inside Virtualbox and it works out fine for my production server. If you're in doubt, try to compile it yourself

 

  1. Check if you're really using the r8169 driver with this command :

lsmod | grep r8169

  2. Download and unzip this pre-compiled driver : r8168.zip

  3. Copy the r8168.ko driver to your Unraid flashdisk (I use /packagescustom)

  4. Copy these line to your go script (change as necessary to reflect where you put the driver)

# Replace Realtek r8169 driver to r8168
cd /lib/modules/2.6.32.9-unRAID/kernel/drivers/net
rmmod r8169
mv r8169.ko r8169.ko.bak
cp /boot/packagescustom/r8168.ko .
depmod -a
insmod r8168.ko

  5. Restart

 

 

It was a long but very educational and fun nights for me investigating the problem :D

Linux experts, please correct me if there's anything wrong with the steps above.

I didn't intend this post to be this long, but if there's one thing I love the most about Unraid is the community so I'd like to contribute however insignificant this is.

 

Credits :

gfjardim's Virtualbox post and wiki

This post on the Ubuntu forums : http://ubuntuforums.org/showthread.php?t=1022411

Link to comment
  • 2 months later...

Hi,

 

I found this post when I noticed my syslog is full of "r8169 eth0 link up" (along with msg repeated xx times) messages. I have had similar issues to the ones you described as well as the occasional dropped packet (though may not be related there). I'm using a Gigabyte H57M-USB3 with an i3-540, so a very similar setup to the one you are using. I've considered purchasing an Intel NIC many times but might give your fix a go. Is this still working well for you?

 

My motherboard comes with the RTL8111D LAN chip, I noticed your board includes the 8111E- do you think this fix would still work on my board? If not is it simple enough to roll back? I'm likely going to update to 5.0 once it goes final (hopefully soon!) and will use the -8168 version if it is still on offer. The issues aren't too noticable other than the syslog messages and occasional "hiccup" as you described so perhaps it is easier to wait.

 

Thanks for the thread :)

Link to comment

Hi,

 

I've moved on to Unraid 5.0-rc3 a couple of months ago and thankfully there hasn't been any of the network errors so far with this build. Haven't had the time to try the rc5-r8168 yet though (I need Virtualbox on my Unraid box and it needs a new build jumping from rc3 to rc5)

 

The last time I used Unraid 4.7 with the r8168 driver, there was no problem at all.

If you want to try this fix and then decided to rollback, it should be simple enough. Just delete the install lines from the go script and reboot, and Unraid should load the stock r8169 driver back again.

 

For me, that 'hiccup' was very annoying because I often transfer large files across my desktop from/to my Unraid server and that the transfer often hung midway (and likely when I was afk) so I wasted time and electric bills.

 

Hope that helps.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.