How to compile just one kernel module?

Please help me. I added a NIC to my old PC runs Rocky 8.6 but it doesn’t start. Network card is D-Link DFE-530TX.
lspci lists out the hardware but there is no installed (driver) module.

My kernel version is 4.18.0
This kernel supports this hardware via VIA Support but it is not part of the installed kernel.

Help me please to understand how I can enable/compile this part without compiling the whole kernel again. (Just for your information; I was able to compile the latest 6.0.0 kernel with this VIA/D-Link support but it took 700+ minutes.)

Could you show us the device ID pairing? Use the command “lspci -nn” and look for [xxxx:yyyy] for your device.

ELRepo might have the driver for it. If not, you can make a request.

1 Like

Hi toracat,

Please check the result of the requested command:

$ lspci -nn
03:01.0 Ethernet controller [0200]: VIA Technologies, Inc. VT6102/VT6103 [Rhine-II] [1106:3065] (rev 43)

How is it possible to find a driver in ELRepo on base of the HW ID ?

Go to ELRepo’s device IDs page.

I thought it was either pata_via or sata_via. Unfortunately, 1106:3065 is not there.

1 Like

Good news.

1106:3065 uses the via_rhine kernel driver. This is not enabled in the regular kernel. However it is enabled in ELRepo’s kernel-ml. You can install it by running:

sudo dnf install elrepo-release
sudo dnf --enablerepo=elrepo-kernel install kernel-ml

Reboot the system to this newly installed kernel.

1 Like

If you prefer using a kmod package, ask ELRepo to provide kmod-via_rhine by submitting a RFE (request for enhancement) at My View - ELRepo Bugs .

This solution worked well. I don’t understand what I have done but it perfectly and quickly worked. But I cannot accept as the answer because this is a workaround.

Perhaps you could help me to understand what I suppose to do when the via-rhine support is there in the installed 4.18.0 kernel but I don’t want to compile the whole kernel because of that.

Is it possible to compile only this part of the kernel ? (Sorry but I don’t know what it is (modul, driver, etc.). I’ve found instructions how to do but they didn’t work on Rocky. Or I was not able to follow them correctly.

Is that really a rare case when someone needs only a little add-on that is placing in the current kernel ? Supposed to be recompiled the whole kernel ? This is a very good article : Building and Installing Custom Linux Kernels - Documentation

The author compiles a new kernel with a feature that was not enabled in the former kernel. This is fine because at the end a brand new kernel version will come out with a new function on kernel level.

But I like my current kernel I’ve found what I need but I cannot enable it. Doesn’t exist an elegant solution just like: make menuconfig => choose-what-you-want => make ?

They talk about something like that but it doesn’t work for me:

Thank you for your kind help in advance.

1 Like

Yes, kernel-ml can be considered as a “workaround”.

This is why I offered a second option: to ask ELRepo for a kmod package.

Kmod packages indeed provide “one kernel module” (some may include more than one). As a bonus, they survive kernel updates. Usually you’d need to rebuild the module for every kernel update. Thanks to the kABI-tracking nature, kmod packages usually work within a given EL minor release (el8, el9, etc). No need to reinstall.

Anyway, I went ahead and built the kmod-via-rhine package for you:



They should be available from ELRepo’s mirror sites shortly.

If you are interested in how to build a driver package for “one kernel module”, take a look at the src.rpm.


Forgot to add one note.

Kmod packages only work for the regular kernel, not for kernel-ml.

Thank you for your effort.
And yes I am very curious how a driver package can be built.
I am going to test it.

I’ve found it here: Repository Mirror for your Cloud Server and Webhosting - Index of /elrepo/elrepo/el8/x86_64/RPMS/

and it’s been available locally already

[user@celeron ~]$ sudo dnf --disablerepo="*" --enablerepo="elrepo" install kmod-via-rhine
[sudo] password for user:
Last metadata expiration check: 0:09:48 ago on Thu 13 Oct 2022 07:47:02 AM CEST.
Dependencies resolved.
 Package                                                     Architecture                                        Version                                                           Repository                                           Size
 kmod-via-rhine                                              x86_64                                              0.0-1.el8_6.elrepo                                                elrepo                                               39 k

Transaction Summary
Install  1 Package

Total download size: 39 k
Installed size: 99 k
Is this ok [y/N]: y
Downloading Packages:
kmod-via-rhine-0.0-1.el8_6.elrepo.x86_64.rpm                                                                                                                                                                 255 kB/s |  39 kB     00:00
Total                                                                                                                                                                                                         55 kB/s |  39 kB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                     1/1
  Installing       : kmod-via-rhine-0.0-1.el8_6.elrepo.x86_64                                                                                                                                                                            1/1
  Running scriptlet: kmod-via-rhine-0.0-1.el8_6.elrepo.x86_64                                                                                                                                                                            1/1
ldconfig: /etc/ hwcap directive ignored

/sbin/ldconfig: /etc/ hwcap directive ignored

  Verifying        : kmod-via-rhine-0.0-1.el8_6.elrepo.x86_64                                                                                                                                                                            1/1


[user@celeron ~]$ find /lib/modules/4.18.0-372.26.1.el8_6.x86_64/ -name *rhine*
[user@celeron ~]$ sudo modprobe via-rhine
[user@celeron ~]$ lsmod
Module                  Size  Used by
via_rhine              40960  0
mii                    16384  1 via_rhine
[bsapi@celeron ~]$ nmcli
enp3s0: connected to enp3s0
        "D-Link System DGE-528T"
        ethernet (r8169), C8:BE:19:41:6C:AB, hw, mtu 1500
        ip4 default
        route4 metric 100
        route4 default via metric 100

enp1s0: unavailable
        "Realtek RTL8111/8168/8411"
        ethernet (r8169), BC:5F:F4:74:12:CF, hw, mtu 1500

enp3s1: unavailable
        "VIA VT6102/VT6103"
        ethernet (via-rhine), 00:50:BA:12:52:49, hw, mtu 1500

This is the most elegant solution I think. Thank you.

Could you help me once more how to access the content of the .src.rpm , please ?

[user@celeron ~]$ sudo rpm -i
warning: user mockbuild does not exist - using root
warning: group mock does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mock does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mock does not exist - using root

I got no experience why I got the warning and what I suppose to see at the end of the process.
Thank you again.

Those are just informational messages. You can ignore them.

There are many sites that show you how to work on rpm packages. For example,

may be one of them.

1 Like

Oh man that’s elegant. You really know what you do.
I’ve found the same via-rhine.c file on github but I couldn’t compile.

Have you written the Makefile by yourself ?

Anyhow your solution is pretty neat. It uses the source code of the driver and it’s wrapped into a rpm package for perfect handling. :clap:t3:

One more thing (hopfully)

[user@celeron ~]$ rpm2cpio kmod-via-rhine-0.0-1.el8_6.elrepo.src.rpm | cpio -idmv
91 blocks
[user@celeron ~]$ ls -l
total 92
-rw-rw-r--. 1 user user 18092 Apr 25  2018 GPL-v2.0.txt
-rw-rw-r--. 1 user user 39174 Oct 12 19:18 kmod-via-rhine-0.0-1.el8_6.elrepo.src.rpm
-rw-rw-r--. 1 user user 21497 Oct 12 19:12 via-rhine-0.0.tar.gz
-rw-rw-r--. 1 user user  6428 Oct 12 19:11 via_rhine.spec
[user@celeron ~]$ tar xvf via-rhine-0.0.tar.gz
[user@celeron ~]$ ls -l
total 92
-rw-rw-r--. 1 user user 18092 Apr 25  2018 GPL-v2.0.txt
-rw-rw-r--. 1 user user 39174 Oct 12 19:18 kmod-via-rhine-0.0-1.el8_6.elrepo.src.rpm
drwxrwxr-x. 2 user user    41 Oct 12 19:10 via-rhine-0.0
-rw-rw-r--. 1 user user 21497 Oct 12 19:12 via-rhine-0.0.tar.gz
-rw-rw-r--. 1 user user  6428 Oct 12 19:11 via_rhine.spec
[user@celeron ~]$ cd via-rhine-0.0/
[user@celeron via-rhine-0.0]$ ls -l
total 76
-rw-rw-r--. 1 user user  1021 Oct 12 19:10 Makefile
-rw-r--r--. 1 user user 71270 Apr 16 02:03 via-rhine.c

Where can you get the via-rhine.spec file ? That looks complex. You implemented this solution pretty fast so I don’t think you wrote it. Can this kind of file be downloaded from somewhere ? The whole solution is so genuine to me that I would like to learn and understand.

(I do not remove my dummy question.) I went through the referred article and I understood how you built the .rpm Included the answer where the .spec file comes ?

This conversation is a gem for me. I learnt a lot.

Thank you.

sudo yum -y install glibc-langpack-en
dnf -y update
dnf -y install epel-release