I wanted to try FreeNAS on my Odroid H2+ NAS system, unfortunately the driver for the Realtek RTL8125B was missing on the FreeBSD OS which is used currently used by FreeNAS.

After reading some post which say something like “There is no way in hell there will be a driver for the RTL8125 unless a big company needs it…”, I came across the following forum topics which pointed me to the actual driver supplied by Realtek.

https://www.xigmanas.com/forums/viewtopic.php?t=15326 https://forum.netgate.com/topic/135850/official-realtek-driver-binary-1-95-for-2-4-4-release/8

Actually I didn’t expected Realtek to provide drivers for FreeBSD but it is available as source for download at:

https://www.realtek.com/en/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software

Compiling the driver

Hint: I also provide the binaries for FreeNAS/FreeBSD 11.3. If you don’t want to compile the driver, you can download the binaries and just install it.

As a first attempt I tried to compile the driver directly on my FreeNAS installation. Unfortunately it looks like FreeNAS comes without a build system. As this is my first contact with FreeBSD, I decided to compile the driver on a virtual machine using a fresh FreeBSD 11.3 installation.

You can get the ISO image at https://download.freebsd.org/ftp/releases/ISO-IMAGES/11.3/FreeBSD-11.3-RELEASE-amd64-dvd1.iso and install it on e.g. a new VitualBox.

During the installation process you should select to install the “System source tree” in order to be able to compile the system and the driver. If you forgot this step you might consider this blog post: https://www.jan0sch.de/post/install-freebsd-sources/. There is nothing else to worry about during the installation. Just follow the process.

FreeBSD Installer

The required steps to build the driver are described in the drivers readme.txt. I will describe the steps again as there are some slight changes necessary.

First of all you might want to backup the original files

cp /usr/src/sys/dev/re/if_re.c /usr/src/sys/dev/re/if_re.c.org
cp /usr/src/sys/modules/Makefile /usr/src/sys/modules/Makefile.org
cp /usr/src/sys/modules/re/Makefile /usr/src/sys/modules/re/Makefile.org
cp /usr/src/sys/amd64/conf/GENERIC /usr/src/sys/amd64/conf/GENERIC.org

Now we remove the driver as part of the kernel build. Remove the following lines from /usr/src/sys/amd64/conf/GENERIC respectively /usr/src/sys/modules/Makefile. I used vi for this. If you’re not familiar with vi some hints:

  • dd –> delete line
  • :wq –> save and exit
  • :q! –> exit without saving (if you messed up ;-)
vi /usr/src/sys/amd64/conf/GENERIC
delete line -->  device              re

vi /usr/src/sys/modules/Makefile
delete line -->  re \

Now the fun part. First we set the build config, then we start the build process. You might consider to get some coffee, this might take a while. After the build we make a reboot.

cd /usr/src/sys/amd64/conf
/usr/sbin/config GENERIC
cd ../compile/GENERIC

make cleandepend
make depend
make
make install
reboot

Now we have the environment to build our driver as a kernel module. First we download the sources from Realtek (or use the link on my webspace). Then we unpack the files to the home dir.

cd ~
fetch http://www.embedded-ideas.de/files/rtl_bsd_drv_v196.04.tgz
tar -zxvf rtl_bsd_drv_v196.04.tgz

Now we copy the files to the right folders…

cd rtl_bsd_drv_v196.04
cp if_re* /usr/src/sys/dev/re/
cp Makefile /usr/src/sys/modules/re/

…and build them.

cd /usr/src/sys/modules/re
make clean
make

Thats it. Copy the if_re.ko onto a USB drive and continue with the installation on FreeNAS.

Update 16.08.20: The build system changed a bit on FreeBSD 12.1. You will find the binaries at /usr/obj/usr/src/amd64.amd64/sys/modules/re. If in doubt, use find / | grep if_re.ko to find the module.

Installing the RTL8125 driver on FreeNAS

As you might not have a working network connection you might consider to copy the driver to a USB stick. If you didn’t wanted to compile it yourself, you can download the binary here :

https://www.embedded-ideas.de/files/if_re-amd64-FreeBSD_11_3.ko

Update 16.08.20: Binaries for TrueNAS 12 BETA 2 (FreeBSD12.1) untested on my target machine but loadable on a virtual machine: https://www.embedded-ideas.de/files/if_re-amd64-FreeBSD_12_1.ko

Please make sure to safe the file on the USB stick as if_re.ko.

On the FreeNAS shell we first have to mount the USB stick. The example expects a FAT32 stick.

mkdir /mnt/usbstick
mount -t msdosfs /dev/da0s1 /mnt/usbstick

Now we have to copy the driver and change the file permissions.

cd /boot/kernel
cp /mnt/usbstick/if_re.ko ./
chown root:wheel if_re.ko
chmod 0555 if_re.ko

In order to load the module on startup we have to add the following line to /boot/loader.conf

vi /boot/loader.conf
add line --> if_re_load="YES"

Again a hint if you are not familiar with vi:

  • i –> change to insert mode
  • ESC –> leave the insert mode
  • :wq –> save and exit
  • :q! –> exit without saving

The driver should be loaded after a reboot. You can check this with

kldstat

if_re.ko should appear in the list. And the network interfaces should be available on FreeNAS.

Interfaces in FreeNAS