How to add a kernel module

It has become clear from @cliffsloane 's post “Failed Ubuntu 22.04 upgrade…” that his upgraded Ubuntu is missing drivers for his Nvidia video card. The drivers are present as an installed package, but do not show in lsmod output.

So we need to work out for Cliff, how to ensure that his kernel loads the nvidia kernel module when it boots.
At this stage we dont even know what the .ko file ( kernel module) is named, let alone how to add it. We need to do some searching.

So to kick it off, here is what I did 10 years ago to add a Realtek ethernet card module to Debian6.

  • download driver from Realtek r8168-8.032.00.tar.bz2
  • unpack it tar -xvf r8168-8.032.00.tar.bz2
  • cd r8168-8.032.00
    make clean modules
    make install
    this puts the .ko file in /lib/modules
  • remove my dud module rmmod r8169
    Note: down to her Cliff is not concerned with… he should already have the module, it just needs to be added in his case
    Carry on
  • Load the new module modprobe r8168
  • Test it lsmod | grep r8168
  • Test the interface it drives ifconfig -a
    ifconfig eth0 up
    So it all works… now we make it permanent
  • Blacklist the old driver
    vi /etc/modprobe.d/blacklist.conf
    add a line
    blacklist r8169
  • depmod -a
  • add the module
    vi /etc/modules
    add a line
    ( or add modprobe r8168 to one of the startup scripts)
  • make it available for boot
    update-initramfs -u
  • reboot
  • see if it is there
    lsmod | grep r8168
    Thats it
    I have a note which says I later added
  • make a file /etc/modprobe.d.r8168.conf
    add a line
    alias eth0 r8168

Now I am sure someone has a better methodology. I raked this up from my 10 year old notes. There are things that are irrelevant today.

Can we please put this into an organised fix that might work for @cliffsloane.


More info
Here is Cliff’s output from `lsmod’ on his Ubuntu22 after upgrade

Module                  Size  Used by
nft_reject_ipv4        16384  2
nf_reject_ipv4         16384  1 nft_reject_ipv4
nft_reject             16384  1 nft_reject_ipv4
nft_ct                 20480  1
nft_masq               16384  1
nft_chain_nat          16384  1
nf_tables             245760  29 nft_reject_ipv4,nft_ct,nft_masq,nft_chain_nat,nft_reject
nfnetlink              20480  1 nf_tables
nf_nat_h323            24576  0
nf_conntrack_h323      90112  1 nf_nat_h323
nf_nat_pptp            20480  0
nf_conntrack_pptp      24576  1 nf_nat_pptp
nf_nat_tftp            16384  0
nf_conntrack_tftp      20480  1 nf_nat_tftp
nf_nat_sip             20480  0
nf_conntrack_sip       40960  1 nf_nat_sip
nf_nat_irc             20480  0
nf_conntrack_irc       20480  1 nf_nat_irc
nf_nat_ftp             20480  0
nf_conntrack_ftp       24576  1 nf_nat_ftp
iptable_nat            16384  0
nf_nat                 49152  9 nf_nat_irc,nf_nat_ftp,nf_nat_tftp,nf_nat_pptp,nft_masq,nf_nat_h323,nft_chain_nat,iptable_nat,nf_nat_sip
nf_conntrack          172032  15 nf_nat_irc,nf_nat,nf_conntrack_tftp,nft_ct,nf_nat_ftp,nf_conntrack_pptp,nf_nat_tftp,nf_conntrack_sip,nf_conntrack_h323,nf_nat_pptp,nf_conntrack_irc,nf_conntrack_ftp,nft_masq,nf_nat_h323,nf_nat_sip
nf_defrag_ipv6         24576  1 nf_conntrack
nf_defrag_ipv4         16384  1 nf_conntrack
libcrc32c              16384  3 nf_conntrack,nf_nat,nf_tables
usblp                  28672  0
drm                   622592  0
uvcvideo              106496  0
ath9k                 217088  0
ath9k_common           45056  1 ath9k
videobuf2_vmalloc      20480  1 uvcvideo
videobuf2_memops       20480  1 videobuf2_vmalloc
videobuf2_v4l2         32768  1 uvcvideo
ath9k_hw              598016  2 ath9k_common,ath9k
snd_usb_audio         352256  0
videobuf2_common       77824  4 videobuf2_vmalloc,videobuf2_v4l2,uvcvideo,videobuf2_memops
snd_hda_codec_realtek   159744  1
videodev              258048  3 videobuf2_v4l2,uvcvideo,videobuf2_common
snd_usbmidi_lib        45056  1 snd_usb_audio
snd_hda_codec_generic   102400  1 snd_hda_codec_realtek
ath                    36864  3 ath9k_common,ath9k,ath9k_hw
ledtrig_audio          16384  1 snd_hda_codec_generic
snd_hda_intel          53248  0
snd_intel_dspcfg       28672  1 snd_hda_intel
snd_intel_sdw_acpi     20480  1 snd_intel_dspcfg
snd_hda_codec         163840  3 snd_hda_codec_generic,snd_hda_intel,snd_hda_codec_realtek
mac80211             1249280  1 ath9k
mc                     65536  5 videodev,snd_usb_audio,videobuf2_v4l2,uvcvideo,videobuf2_common
intel_rapl_msr         20480  0
intel_rapl_common      40960  1 intel_rapl_msr
snd_hda_core          110592  4 snd_hda_codec_generic,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek
joydev                 32768  0
input_leds             16384  0
cfg80211              974848  4 ath9k_common,ath9k,ath,mac80211
x86_pkg_temp_thermal    20480  0
intel_powerclamp       20480  0
snd_hwdep              16384  2 snd_usb_audio,snd_hda_codec
libarc4                16384  1 mac80211
snd_pcm               143360  4 snd_hda_intel,snd_usb_audio,snd_hda_codec,snd_hda_core
snd_seq_midi           20480  0
snd_seq_midi_event     16384  1 snd_seq_midi
snd_rawmidi            49152  2 snd_seq_midi,snd_usbmidi_lib
mei_hdcp               24576  0
mei_me                 40960  1
kvm_intel             372736  0
snd_seq                77824  2 snd_seq_midi,snd_seq_midi_event
kvm                  1028096  1 kvm_intel
crct10dif_pclmul       16384  1
ghash_clmulni_intel    16384  0
snd_seq_device         16384  3 snd_seq,snd_seq_midi,snd_rawmidi
snd_timer              40960  2 snd_seq,snd_pcm
snd                   106496  12 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hwdep,snd_hda_intel,snd_usb_audio,snd_usbmidi_lib,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_pcm,snd_rawmidi
aesni_intel           376832  0
mei                   135168  3 mei_hdcp,mei_me
soundcore              16384  1 snd
crypto_simd            16384  1 aesni_intel
cryptd                 24576  2 crypto_simd,ghash_clmulni_intel
at24                   24576  0
rapl                   20480  0
intel_cstate           20480  0
wmi_bmof               16384  0
mac_hid                16384  0
sch_fq_codel           20480  2
hwmon_vid              16384  0
coretemp               24576  0
ipmi_devintf           20480  0
ipmi_msghandler       122880  1 ipmi_devintf
msr                    16384  0
parport_pc             49152  1
ppdev                  24576  0
lp                     28672  0
parport                69632  3 parport_pc,lp,ppdev
ramoops                32768  0
mtd                    77824  0
efi_pstore             16384  0
reed_solomon           28672  1 ramoops
pstore_blk             16384  0
pstore_zone            32768  1 pstore_blk
ip_tables              32768  1 iptable_nat
x_tables               53248  2 ip_tables,iptable_nat
autofs4                49152  2
hid_jabra              16384  0
hid_generic            16384  0
usbhid                 65536  0
hid                   151552  3 usbhid,hid_generic,hid_jabra
ahci                   45056  2
crc32_pclmul           16384  0
i2c_i801               36864  0
i2c_smbus              20480  1 i2c_i801
xhci_pci               24576  0
libahci                45056  1 ahci
e1000e                299008  0
lpc_ich                28672  0
xhci_pci_renesas       20480  1 xhci_pci
wmi                    32768  1 wmi_bmof
video                  61440  0

I have looke hard, but I cant see any nvidia module… Is that correct?

But he has the nvidia package installed … here is dpkg -l output

ii  nvidia-340                                    340.108-0ubuntu8                           amd64        Transitional package for xserver-xorg-video-nouveau
ii  nvidia-340-dev                                340.108-0ubuntu8                           amd64        Transitional package for xserver-xorg-video-nouveau
ii  nvidia-340-uvm                                340.108-0ubuntu8                           amd64        Transitional package for xserver-xorg-video-nouveau
ii  nvidia-libopencl1-340                         340.108-0ubuntu8                           amd64        Transitional package for xserver-xorg-video-nouveau
ii  nvidia-opencl-icd-340                         340.108-0ubuntu8                           amd64        Transitional package for xserver-xorg-video-nouveau
ii  nvidia-settings                               510.47.03-0ubuntu1                         amd64        Tool for configuring the NVIDIA graphics driver
ii  screen-resolution-extra                       0.18.2                                     all          Extension for the nvidia-settings control panel

So my conclusion is, he should have the kernel module in
/lib/modules/uname -r/kernel/drivers/video

But I am worried about this dpkg -l | grep xorg output

ii  libcuda1-340                                  340.108-0ubuntu8                           amd64        Transitional package for xserver-xorg-video-nouveau
ii  nvidia-340                                    340.108-0ubuntu8                           amd64        Transitional package for xserver-xorg-video-nouveau
ii  nvidia-340-dev                                340.108-0ubuntu8                           amd64        Transitional package for xserver-xorg-video-nouveau
ii  nvidia-340-uvm                                340.108-0ubuntu8                           amd64        Transitional package for xserver-xorg-video-nouveau
ii  nvidia-libopencl1-340                         340.108-0ubuntu8                           amd64        Transitional package for xserver-xorg-video-nouveau
ii  nvidia-opencl-icd-340                         340.108-0ubuntu8                           amd64        Transitional package for xserver-xorg-video-nouveau
ii  python3-xkit                                  0.5.0ubuntu5                               all          library for the manipulation of xorg.conf files (Python 3)
ii  xorg                                          1:7.7+23ubuntu2                            amd64        X.Org X Window System
ii  xorg-docs-core                                1:1.7.1-1.2                                all          Core documentation for the X Window System
ii  xorg-sgml-doctools                            1:1.11-1.1                                 all          Common tools for building X.Org SGML documentation
ii  xserver-xorg                                  1:7.7+23ubuntu2                            amd64        X.Org X server
ii  xserver-xorg-core                             2:21.1.3-2ubuntu2.1                        amd64        Xorg X server - core server
ii  xserver-xorg-hwe-18.04                        3:14.6                                     amd64        Transitional package for xserver-xorg-hwe-18.04
ii  xserver-xorg-input-all                        1:7.7+23ubuntu2                            amd64        X.Org X server -- input driver metapackage
ii  xserver-xorg-input-libinput                   1.2.1-1                                    amd64        X.Org X server -- libinput input driver
ii  xserver-xorg-input-wacom                      1:1.0.0-3ubuntu1                           amd64        X.Org X server -- Wacom input driver
ii  xserver-xorg-legacy                           2:21.1.3-2ubuntu2.1                        amd64        setuid root Xorg server wrapper
ii  xserver-xorg-video-all                        1:7.7+23ubuntu2                            amd64        X.Org X server -- output driver metapackage
ii  xserver-xorg-video-amdgpu                     22.0.0-1build1                             amd64        X.Org X server -- AMDGPU display driver
ii  xserver-xorg-video-ati                        1:19.1.0-2ubuntu1                          amd64        X.Org X server -- AMD/ATI display driver wrapper
ii  xserver-xorg-video-fbdev                      1:0.5.0-2build1                            amd64        X.Org X server -- fbdev display driver
ii  xserver-xorg-video-intel                      2:2.99.917+git20210115-1                   amd64        X.Org X server -- Intel i8xx, i9xx display driver
ii  xserver-xorg-video-nouveau                    1:1.0.17-2build1                           amd64        X.Org X server -- Nouveau display driver
ii  xserver-xorg-video-nouveau-hwe-18.04          3:14.6                                     amd64        Transitional package for xserver-xorg-video-nouveau-hwe-18.04
ii  xserver-xorg-video-qxl                        0.1.5+git20200331-3                        amd64        X.Org X server -- QXL display driver
ii  xserver-xorg-video-radeon                     1:19.1.0-2ubuntu1                          amd64        X.Org X server -- AMD/ATI Radeon display driver
ii  xserver-xorg-video-vesa                       1:2.5.0-1build4                            amd64        X.Org X server -- VESA display driver
ii  xserver-xorg-video-vmware                     1:13.3.0-3build1                           amd64        X.Org X server -- VMware display driver

It has xserver-xorg-video-nouveau but no xorg line mentioning nvidia.

And, Cliffs card is a gts240… not a 340?

01:00.0 VGA compatible controller: NVIDIA Corporation G92 [GeForce GTS 240] (rev a2)

We need advice from someone who has installed Nvidia prorpietary drivers and modules in Ubuntu?


Duckducking a bit I read:

nvidia-graphics-drivers-340 (340.108-0ubuntu8) hirsute; urgency=medium

Probably a solution:

If you are still looking for an answer, the solution is: ppa:kelebek333/nvidia-legacy

Installing the drivers from PPA, nvidia-updates-340 is available.

So, install the PPA:

sudo add-apt-repository ppa:kelebek333/nvidia-legacy

sudo apt update

next, you need to install the packages:

sudo apt install nvidia-340-updates nvidia-340-updates-dev xorg-modulepath-fix

Then, reboot. You should have the NVidia drivers 340.108 running fine.

Not Ubuntu, but Debian.

lsmod |grep nvi
nvidia_drm             73728  7
drm_kms_helper        278528  1 nvidia_drm
nvidia_modeset       1204224  10 nvidia_drm
nvidia              35389440  404 nvidia_modeset
drm                   626688  11 drm_kms_helper,nvidia,nvidia_drm

I would look for /etc/modprob.d/ whatever conf, if there’s something that may blacklist nvidia driver?
If there is, it is the cause why the driver is not loaded.
If that was an inplace upgrade (according to my readings it was), I can imagine nvidia dirver packages were not correctly upgraded. I’m not a user of Ubuntu, so I can just guess, some process may blacklisted nvidia driver?
However, the time propietary dirver was installed, that surely blakclisted the nouveau driver, so may be this machine took a sit between two chairs? :slight_smile:
Just guessing…
If that was my machine, I’d remove all nvidia related package, something like
apt purge nvidia*
To be sure, I’d take a system snapshot with

Just in case…
After apt purge, I’d look for where the nouveau is blacklisted.
It should be something like /etc/modprobe.d/nvidia-blacklists-nouveau.conf
Reads like this:

cat /etc/modprobe.d/nvidia-blacklists-nouveau.conf
# You need to run "update-initramfs -u" after editing this file.

# see #580894
blacklist nouveau

I’d rename this file, say to nvidia-blacklists-nouveau.conf.bak, so it will be ignored.
I’d issue the update-initramfs -u command, as it is suggested.
Then reboot…
If I’m right, Ubunut should boot up with the nouveau driver…
After that I’d try to reinstall the proprietary drivers, if still needed.

1 Like

340 is the drivers version number, gts240 is the name of that cards chipset :wink:

1 Like

10 years and GUI Linux still did not fix this issue. :laughing:

When saying “issue” in this context, I am talking about the whole needing to load a kernel module thing to make something work, which should always work by default, no matter what and without needing any user interaction beyond installing a program, whatsoever…

On Windows it’s just a matter of running an installer. Done.

Additionally, the fact of how much effort you put in into this issue, kind of proves the point we were trying to make. It just does not make sense. Oh and you aren’t even done, yet. You still need to continue horsing around with this issue.

1 Like

And when something fails, it shows an error message like “Error #80002, contact the administrator”. Done :laughing:

1 Like

When does it ever fail like that?

buuuuuuuuuurn ~~~~~~~~~~~~~~~

I am regularly updating my NVIDIA drivers to the newest driver versions (impossible on Linux btw, because of delays and compatibility issues with the newest versions) and never had an issue where the installation just failed.

The problem is, that sometimes my sound settings reset. It takes like 3 minutes to fix the sound settings and it’s always the same, so no tinkering around required. However, nothing breaks. Everything works.

Imagine a fairly recent NVIDIA graphics card just working on Linux… :open_mouth: That would be astonishing.

Similar message I got long ago from Windows 7, when tried to install an update.
This is more recent, however I did not receiv it myself:

Is that recent enough?

Supported products:

GeForce RTX 30 Series (Notebooks):

GeForce RTX 3080 Ti Laptop GPU, GeForce RTX 3080 Laptop GPU, GeForce RTX 3070 Ti Laptop GPU, GeForce RTX 3070 Laptop GPU, GeForce RTX 3060 Laptop GPU, GeForce RTX 3050 Ti Laptop GPU, GeForce RTX 3050 Laptop GPU

GeForce RTX 30 Series:

GeForce RTX 3090 Ti, GeForce RTX 3090, GeForce RTX 3080 Ti, GeForce RTX 3080, GeForce RTX 3070 Ti, GeForce RTX 3070, GeForce RTX 3060 Ti, GeForce RTX 3060, GeForce RTX 3050

GeForce RTX 20 Series (Notebooks):

GeForce RTX 2080 SUPER, GeForce RTX 2080, GeForce RTX 2070 SUPER, GeForce RTX 2070, GeForce RTX 2060, GeForce RTX 2050

GeForce RTX 20 Series:

GeForce RTX 2080 Ti, GeForce RTX 2080 SUPER, GeForce RTX 2080, GeForce RTX 2070 SUPER, GeForce RTX 2070, GeForce RTX 2060 SUPER, GeForce RTX 2060

1 Like

I think I have seen that as a joke online somewhere, though I never saw something like this in reality. Is it even a real message or just a joke?
The worst errors still give error codes which you could look up online. And since Windows is very popular, you’ll always get plenty of results for those error codes, most of the time with accompanying solutions.

I am currently on 516.94, so I am still having an even more recent version.

So, then you are the absolute winner. :wink:

@kovacslt ,
Well, we certainly got some up to date expert advice.
Thank you for that, my experience of kernel modules is just too old and limited and I have never had to deal with nvidia.

I do t think that @Cliffsloane has the nouveau packages installed. He certainly has the nvidia packages.

Yes, it would not be surprising if the inplace upgrade blacklisted the nvidia drivers, especially now we know the drivers for that card are incompatable with current kernels

Cliff has Mint21 with nouveau drivers running in the same machine. He says he gets tearing .
So I expect Ubuntu with nouveau would do the same.
Do you think he should try to setup the nvidia drivers?
What is the reason for getting it going with nouveau drivers first, before trying with nvidia?

Regards, and thanks

No, after about 2 years, by the time I got to Debian 7 or 8, it started loading the right driver at install time.
I guess that is the time it took Debian to catch up with drivers for new NIC’s

“Only” 2 years… :smiley:

According to that, I’d create a nouveau.conf in /etc/X11/xorg.conf.d/ -on Debian.
I know, Ubuntu and Mint store this somewher under /usr/share, but can’t remember the exact path.
The content of that file would be:

Section "Device"
    Identifier "Device0"
    Driver "nouveau"
    Option "GLXVBlank" "true"

I think, GLXVblank shuld eliminate tearing.

1 Like

@Akito, please stop flooding with your mocking, negative attitude.
It doesn’t help. Keep using Windows, as it is much more reliable. You can also contact and/or join Debian (or alternatively your least hated other distributions) development team and contribute to make things better.
And let us try to help Cliff, and find the solution.
Thanks. Peace… :peace_symbol:

1 Like

It’s the default, built-in driver, and it surely works with the kernel in use.

1 Like

I wanted to point out the pointlessness of this conversation. This shouldn’t happen. It should just work.
It was also a reaction to the apologetic comments from the thread this one is based on. Too many times, it was mentioned that it’s “not Linux’ fault” when it actually is. So, I had to point out, how it is the fault of that.

No, won’t do that. They are using antiquated mindsets, resulting in antiquated technologies and products. I mean, how in hell were Linux elitists considering http to be superior to https for repositories. Linux elitists need to quit those projects and designers should take their places. We need more UX and less “jUsT LeArN ScRiiPtiinG BrO”. Linux elitists are a joke, because their minds are far away from this world’s reality.
The reality is, we need computers to work for humans, not the other way around.

What is the problem? Oh yes, Linux GUI fucked it all up, again. So, if you want to help, fix Linux or whatever. Cliff does not need help. Linux does.

Just checking.
Can I limit my actions to these steps?

  1. Boot into recovery mode
  2. Enable network, go to root
  3. Rename nvidia-blacklists-nouveau.conf to nvidia-blacklists-nouveau.conf.bak
  4. run update-initramfs -u
  5. Resume boot

Would that have a likelihood of success?

If you do step 1…4 that will reenable nouveau driver.

I’d comletely reboot. Ubuntu should then boot up with the already reenabled nouveau.
Hopefully that solves part of your problems.
If you find, the videocard has much less power than before, you probably will need the proprietary driver. For that you will need that ppa, hopefully that solves all your related problems.

1 Like