5

I have purchased a new desktop and I am trying to run Ubuntu in dual boot with windows 10. I have disabled secure boot and windows fast boot. When I log in to Ubuntu it does not connect to internet via ethernet cable.

sudo lshw -C network Shows realtek driver is unclaimed.

The solution I have searched is to install r8125 driver but I just cannot get the steps accurately. Request to let me know what are the installation steps of installing r8125 driver and run the internet from ethernet cable.

  • Ubuntu 20.04 with kernel 5.8.0-53-generic: I've found that using @nospam solution and with some modifications/adaptations, worked for my setup. Just commented (#) the lines "REMAKE_INITRD" and "CLEAN", because apparently the kernel does this automatically. – Fer B. May 27 '21 at 09:41
  • (2/2)...and this value for: DEST_MODULE_LOCATION[0]="/kernel/drivers/net/ethernet/realtek/r8125" – Fer B. May 27 '21 at 09:49

4 Answers4

20

To avoid having to reinstall the driver after every kernel update, create a file called dkms.conf in the NIC's source directory with these lines:

PACKAGE_NAME="r8125"
PACKAGE_VERSION="9.003.05"
BUILT_MODULE_NAME[0]="$PACKAGE_NAME"
DEST_MODULE_LOCATION[0]="/updates/dkms"
AUTOINSTALL="YES"
REMAKE_INITRD="YES"
CLEAN="rm src/@PKGNAME@.ko src/*.o || true"

Modify 9.003.05 to the version number that you have the source code for. To install the driver for the first time:

sudo cp -R /path.to/source/ /usr/src/r8125-9.003.05
sudo dkms add -m r8125 -v 9.003.05
sudo dkms build -m r8125 -v 9.003.05
sudo dkms install -m r8125 -v 9.003.05

To update the version, remove the current one first, remembering to change to the correct version number:

sudo dkms remove r8125/9.002.02 --all
sudo rm -rf /usr/src/r81259.002.02/
sudo dkms status

After the first install, dkms will automatically build and install the driver for you. You will, of course, need dkms installed first.

nospam
  • 422
  • This works great! +1 However, you might see a warning when running dkms status about the installed version being different than the built version. If you do, just run sudo dkms uninstall -m r8125 -v 9.003.05 -k <kernel version>-generic && sudo dkms install -m r8125 -v 9.003.05 -k <kernel version>-generic --force – Terrance Apr 14 '21 at 03:27
  • Thanks for this great fix!

    I ended up scripting it, and this is the result: https://github.com/nextcloud/vm/blob/master/network/asusnuc/pn51.sh

    – Daniel Hansson Jul 19 '21 at 18:42
  • 2
    If using a newer version see answer from Martijn https://askubuntu.com/a/1336708/253486 – rlhelinski Sep 03 '21 at 16:44
  • 1
    Note, that the "NIC's source directory" is not the src directory in the the extracted driver folder, but the one that contains the src directory, the Makefile etc. – user1768761 Jun 08 '22 at 16:04
5

Somehow stuff breaks if I use the config from @nospam. The following config works for the newest versions, I added the kernelver to the build

$ cat dkms.conf
PACKAGE_NAME="realtek-r8125"
PACKAGE_VERSION="9.005.01"
BUILT_MODULE_NAME[0]="r8125"
DEST_MODULE_LOCATION[0]="/updates"
BUILT_MODULE_LOCATION[0]="src"
MAKE="'make' KVER=${kernelver} BSRC=/lib/modules/${kernelver} all"
AUTOINSTALL="yes"
REMAKE_INITRD="yes"
CLEAN="rm src/@PKGNAME@.ko src/*.o || true"

Or upgrade to the latest version of ubuntu worked for me

  • 1
    Thanks, your version also works with 9.005.06, while @nospams would not build. – Barnaba Jul 21 '21 at 12:21
  • Even this... It works for a while then after a kernel update dkms status shows r8125, 9.009.01 is installed, but the network card is again unclaimed... It's incredible that making basic Ethernet work can be so demanding on Linux... Edit. I needed 9.009.02 for the new kernel version. – user1768761 Jul 19 '22 at 13:11
  • On Ubuntu 22.04, ethernet suddenly started to hang after working fine since upgrade from 20.04 to 22.04. Following answer 1 & 2 did not solve problem. Any ideas? – John Rose Jun 02 '23 at 14:41
  • My guess is a conflic in drivers or maybe you need a newer version of that driver. – Martijn van Wezel Jul 05 '23 at 15:32
2
  • Obtain file from Realtek here (They make it very complicated :-( )
  • Unzip
  • In terminal, change into directory and run sudo ./autorun.sh
  • I did this but now whenever I update my system, I lose this install (and thus also lose network access) and have to run the ./autorun again. (It goes faster, of course, since it doesn't have to do the cofig and compile steps again, but still.....)

    How do I make this update "stick"?

    – Rob Cranfill Oct 05 '20 at 02:43
  • 1
    @RobCranfill you can add ./autorun command to bashrc or crontab to execute it automatically on each system startup. – Ayush Srivastava Nov 05 '20 at 06:12
  • I don’t think re-building on every startup is the most elegant solution, but thanks for the thought. The new comment detailing the use of DKMS seems more appropriate. – Rob Cranfill Nov 07 '20 at 07:45
  • I just got a new Alienware Aurora R12 with a Killer E3100G 2.5 GB Ethernet Controller and with the 5.8 kernel a stock Ubuntu 20.04 install did not recognize it, this answer worked perfectly to resolve the concern, how I'm the first upvote for this life saver of an answer I'm not sure. – cdahms Jun 20 '21 at 23:54
0

I found that upgrading to Ubuntu 20.04 is another solution. I have a brand new B550 board and the existing Ubuntu 18.04 installation didn't pick up the 2.5G ethernet, but upgrading to 20.04 solved it for me.

robvdl
  • 83
  • 1
    It didn't for me; what worked was this answer (on LZS 20.04): https://askubuntu.com/a/1289417 – Tobias Geisler Jun 17 '21 at 09:41
  • Tobias you are correct, it didn't work for me either but I didn't find out till later which is why I am updating this post.

    What seems to have happened is I was using an older kernel on 18.04, compiled the network driver, it said it failed but apparently didn't.

    Then I upgraded to 20.04, it appeared to work, until I got my first kernel update and then it was back to square one.

    I believe 22.04 will be the first Ubuntu LTS to properly support 2.5G ethernet out of the box, meanwhile compiling the driver is the only option.

    – robvdl Jul 21 '21 at 03:43