Akmod-nvidia installation failing and pointing to old kernel version

I upgraded from Fedora 39 to Fedora 40 Kinoite. Sadly I have issues reinstalling the akmod-nvidia driver, because it tries to use the old kernel from Fedora 39 in the installation process. I don’t understand why. This is not necessarily a Fedora 40 issue, I already had problems to upgrade to newer minor versions of Fedora 39. I will now point out the steps in more detail:

  1. Back in Fedora 39 I noticed I already had issues to install Fedora 40 (or newer versions of 39), while the akmod-nvidia driver was installed. In terminal I was getting an error while upgrading pointing out an issue with akmod-nvidia. Right now I don’t have more details about this, but probably good to know.

  2. As far as I know it is good practice to remove all LayeredPackages when doing a major upgrade, so I did. That included the nvdia driver, but also other related packages such as kernel-devel.

  3. After that the upgrade worked.

  4. While launching I had to make sure in the GRUB menu to remove some parameters so Fedora falls back to the vanilla Nvidia Driver.

  5. Fedora 40 is now launched, no LayeredPackages installed.

  6. I made sure to install at the very start kernel-devel via

rpm-ostree install kernel-devel-$(uname -r) kernel-headers
  1. Then I reinstalled
rpmfusion-free-release-40-1.noarch

and

rpmfusion-nonfree-release-40-1.noarch

as LocalPackages.

  1. I also installed akmods (indepedently of akmod-nvidia).

  2. After rebooting I hoped the akmod-nvidia driver finally would work, but nope. The error message I get over and over:

rpm-ostree install akmod-nvidia
Checking out tree 4f7fdec... done
Enabled rpm-md repositories: fedora-cisco-openh264 updates fedora rpmfusion-free-updates rpmfusion-free rpmfusion-nonfree-updates rpmfusion-nonfree updates-archive
Importing rpm-md... done
rpm-md repo 'fedora-cisco-openh264' (cached); generated: 2023-12-11T14:43:50Z solvables: 4
rpm-md repo 'updates' (cached); generated: 2024-05-04T01:15:25Z solvables: 10247
rpm-md repo 'fedora' (cached); generated: 2024-04-14T18:51:11Z solvables: 74881
rpm-md repo 'rpmfusion-free-updates' (cached); generated: 2024-05-02T15:58:05Z solvables: 68
rpm-md repo 'rpmfusion-free' (cached); generated: 2024-04-20T12:11:51Z solvables: 422
rpm-md repo 'rpmfusion-nonfree-updates' (cached); generated: 2024-05-02T16:17:35Z solvables: 54
rpm-md repo 'rpmfusion-nonfree' (cached); generated: 2024-04-20T12:18:23Z solvables: 194
rpm-md repo 'updates-archive' (cached); generated: 2024-05-04T01:37:42Z solvables: 8507
Resolving dependencies... done
Checking out packages... done
Running pre scripts... done
Running post scripts... done
error: Running %post for akmod-nvidia: bwrap(/bin/sh): Child process killed by signal 1; run `journalctl -t 'rpm-ostree(akmod-nvidia.post)'` for more information

Here is the start of the error log. It is a lot of log, but the point is it keeps talking about the old kernel version.

May 04 16:31:05 pizzapc rpm-ostree(akmod-nvidia.post)[2407]: Building /usr/src/akmods/nvidia-kmod-550.78-1.fc39.src.rpm for kernel 6.6.13-200.fc39.x86_64
May 04 16:31:05 pizzapc rpm-ostree(akmod-nvidia.post)[2414]: ERROR: Files needed for building modules against kernel
May 04 16:31:05 pizzapc rpm-ostree(akmod-nvidia.post)[2414]:  6.6.13-200.fc39.x86_64 could not be found as the following
May 04 16:31:05 pizzapc rpm-ostree(akmod-nvidia.post)[2414]:  directories are missing:
May 04 16:31:05 pizzapc rpm-ostree(akmod-nvidia.post)[2414]:  /usr/src/kernels/6.6.13-200.fc39.x86_64/
May 04 16:31:05 pizzapc rpm-ostree(akmod-nvidia.post)[2414]:  /usr/lib/modules/6.6.13-200.fc39.x86_64/build/
-- Boot dde9f72bb5e7439c828884a654c98dab --
May 04 18:35:11 pizzapc rpm-ostree(akmod-nvidia.post)[2870]: Building /usr/src/akmods/nvidia-kmod-550.78-1.fc40.src.rpm for kernel 6.6.13-200.fc39.x86_64
May 04 18:35:11 pizzapc rpm-ostree(akmod-nvidia.post)[2877]: ERROR: Files needed for building modules against kernel
May 04 18:35:11 pizzapc rpm-ostree(akmod-nvidia.post)[2877]:  6.6.13-200.fc39.x86_64 could not be found as the following
May 04 18:35:11 pizzapc rpm-ostree(akmod-nvidia.post)[2877]:  directories are missing:
May 04 18:35:11 pizzapc rpm-ostree(akmod-nvidia.post)[2877]:  /usr/src/kernels/6.6.13-200.fc39.x86_64/
May 04 18:35:11 pizzapc rpm-ostree(akmod-nvidia.post)[2877]:  /usr/lib/modules/6.6.13-200.fc39.x86_64/build/
May 04 18:37:06 pizzapc rpm-ostree(akmod-nvidia.post)[3593]: Building /usr/src/akmods/nvidia-kmod-550.78-1.fc40.src.rpm for kernel 6.6.13-200.fc39.x86_64
  1. I stumbled upon threads with similar (but not the same) issue, from there I tried the classics such as:
sudo akmods --force

This won’t work, because no akmod-nvidia is installed right now in the first place.

Another one:

sudo depmod -a

Where I get a strange error, even tho i should be able to write:

depmod: ERROR: openat(/lib/modules/6.8.8-300.fc40.x86_64, modules.dep.11748.57466.1714856781, 301, 644): Read-only file system
depmod: ERROR: openat(/lib/modules/6.8.8-300.fc40.x86_64, modules.dep.bin.11748.57466.1714856781, 301, 644): Read-only file system
depmod: ERROR: openat(/lib/modules/6.8.8-300.fc40.x86_64, modules.alias.11748.57466.1714856781, 301, 644): Read-only file system
depmod: ERROR: openat(/lib/modules/6.8.8-300.fc40.x86_64, modules.alias.bin.11748.57466.1714856781, 301, 644): Read-only file system
depmod: ERROR: openat(/lib/modules/6.8.8-300.fc40.x86_64, modules.softdep.11748.57466.1714856781, 301, 644): Read-only file system
depmod: ERROR: openat(/lib/modules/6.8.8-300.fc40.x86_64, modules.symbols.11748.57466.1714856781, 301, 644): Read-only file system
depmod: ERROR: openat(/lib/modules/6.8.8-300.fc40.x86_64, modules.symbols.bin.11748.57466.1714856781, 301, 644): Read-only file system
depmod: ERROR: openat(/lib/modules/6.8.8-300.fc40.x86_64, modules.builtin.bin.11748.57466.1714856781, 301, 644): Read-only file system
depmod: ERROR: openat(/lib/modules/6.8.8-300.fc40.x86_64, modules.builtin.alias.bin.11748.57466.1714856781, 301, 644): Read-only file system
depmod: ERROR: openat(/lib/modules/6.8.8-300.fc40.x86_64, modules.devname.11748.57466.1714856781, 301, 644): Read-only file system

So to sum it up, why is akmod-nvidia still trying to use my old kernel version? How can I fix this? I was trying the whole day, I don’t know anymore what to do.

Added f40

Added silverblue