How best to clean /var/cache/akmods/nvidia and /var/cache/akmods/nvidia-open

Hello

before upgrading from F42 to F43 I checked my /var partition and recognized that 2 directories on /var use about 5 GB in total:
/var/cache/akmods/nvidia
/var/cache/akmods/nvidia-open (uses 4.3 GB)

There is a lot of entries for old nvidia dreivers. Any idea how I could remove some files below /var/cache/akmods/ ? Manually delete the ones of the old driver versions?

Thank you in advance
Jochen

Usually, I simply delete anything in directories with the name ‘cache’ if I feel like it. Any well written software should always fall back to downloading the original data again if there is a cache miss.

This seems a continuation of Heavy flatpak usage of /var

Did you check the last posts in that thread?

Hello Jeff,

no, I did not recognize your last post in the other thread :wink: . After Joe’s “I’d suggest making a new thread for that since that’s a new issue.” I opened this one.
I will check your hints in the other post later today and will keep you informed.

Thank you
Jochen

Looks like akmod-nvidia is missing a directive for systemd-tmpfiles to clean in /var/cache/akmods/nvidia. Btw., you should not use nvidia-open anyway.

I am not sure why nvidia-open is part of akmods. Can you please explain shortly why nvidia-open might harm?

jojo@waldstadion:~$ sudo dnf5 clean all
[sudo] password for jojo: 
Removed 149 files, 128 directories (total of 203 MiB). 0 errors occurred.
jojo@waldstadion:~$ sudo dnf4 clean all
60 files removed

The commands above not clean anything in /var/cache/akmods. So I now deleted all files below /var/cache/akmods except those for the currently nvidia driver. That helped
now /var has 11GB unused, should be sufficient to upgrade from F42 to F42.

1 Like

Why should it? dnf has no business with akmods. It’s the location used by akmods to build the kernel modules. You can remove the nvidia and nvidia-open directories. Akmods will recreate the dir when it builds new kernel modules.

EDIT: the modules are build in /tmp/ but the created rpm and build logfiles are saved in /var/cache/akmods/<modulename>

1 Like

akmod-nvidia-open is an alternative to akmod-nvidia.
dnf list akmod-nvidia\*

Updating and loading repositories:
Repositories loaded.
Available packages
akmod-nvidia.x86_64       3:580.119.02-1.fc42  rpmfusion-nonfree-updates
akmod-nvidia-390xx.x86_64 3:390.157-22.fc42    rpmfusion-nonfree-updates
akmod-nvidia-470xx.x86_64 3:470.256.02-13.fc42 rpmfusion-nonfree-updates
akmod-nvidia-open.x86_64  3:580.119.02-1.fc42  rpmfusion-nonfree-tainted

it does not harm, but it provides no advantage to akmod-nvidia, unless you need to apply custom patches to the kernel module sources.
If you have installed only akmod-nvidia, then the nvidia-open directory is of no use anyway. You may have had nvidia-open installed at some point.

In the early days of nvidia-open it was necessary to have different paths of distribution which resulted in conflicts of files/packages with different versioning and ownership. This is why nvidia-open resides in rpmfusion-nonfree-tainted so users can install one or the other at their choice.

Today the full features of nvidia open are included in akmod-nvidia and the system is smart enough to check what gpu is installed so it builds either the proprietary driver for those not supported by the open version or the open version for everything it does support. This has been the case since about the 570 driver if I recall properly.

It is not necessary to have nvidia-open as a separate packaging chain any more.

This was never necessary! Pls do some fact checking first! akmod-nvidia-open provides full kernel source code released by nvidia GitHub - NVIDIA/open-gpu-kernel-modules: NVIDIA Linux open GPU kernel module source or Index of /XFree86/NVIDIA-kernel-module-source

akmod-nvidia bundles the kernel modules and source released by nvidia in the run installers! Since 515.x, this also includes the so called open kernel modules. But most of those are pre-compiled and only the source files interacting directly with the kernel are included. This leads to shorter compile time compared to the akmod-nvidia-open package.

I remember that last summer I struggled with nvdia because my NVIDIA GPU did not work with my HDMI interface
anyway:

jojo@waldstadion:~$ rpm -qa | grep kmod
kmod-libs-33-3.fc42.x86_64
kmod-33-3.fc42.x86_64
kmodtool-1.1-13.fc42.noarch
akmods-0.6.2-3.fc42.noarch
kmod-nvidia-6.17.10-200.fc42.x86_64-580.105.08-1.fc42.x86_64
kmod-nvidia-open-6.17.10-200.fc42.x86_64-580.105.08-1.fc42.x86_64
xorg-x11-drv-nvidia-kmodsrc-580.119.02-1.fc42.x86_64
akmod-nvidia-580.119.02-1.fc42.x86_64
akmod-nvidia-open-580.119.02-1.fc42.x86_64
kmod-nvidia-open-6.17.13-200.fc42.x86_64-580.119.02-1.fc42.x86_64
kmod-nvidia-6.17.13-200.fc42.x86_64-580.119.02-1.fc42.x86_64
kmod-nvidia-6.17.11-200.fc42.x86_64-580.119.02-1.fc42.x86_64
kmod-nvidia-open-6.17.11-200.fc42.x86_64-580.119.02-1.fc42.x86_64

jojo@waldstadion:~$ rpm -qa | grep kmod-nvidia-open
kmod-nvidia-open-6.17.10-200.fc42.x86_64-580.105.08-1.fc42.x86_64
akmod-nvidia-open-580.119.02-1.fc42.x86_64
kmod-nvidia-open-6.17.13-200.fc42.x86_64-580.119.02-1.fc42.x86_64
kmod-nvidia-open-6.17.11-200.fc42.x86_64-580.119.02-1.fc42.x86_64

Should I now try to remove the akmod-nvidia-open-580.119.02-1.fc42.x86_64 ?

I just go in there (/var/cache/akmods/*) occasionally and remove all the files related to kernels I no longer have.

jojo@waldstadion:~$ sudo dnf remove kmod-nvidia-open-6.17.10-200.fc42.x86_64-580.105.08-1.fc42.x86_64 akmod-nvidia-open-580.119.02-1.fc42.x86_64 kmod-nvidia-open-6.17.13-200.fc42.x86_64-580.119.02-1.fc42.x86_64 kmod-nvidia-open-6.17.11-200.fc42.x86_64-580.119.02-1.fc42.x86_64
[sudo] password for jojo: 
Package                                                 Arch         Version                                                  Repository                                 Size
Removing:
 akmod-nvidia-open                                      x86_64       3:580.119.02-1.fc42                                      rpmfusion-nonfree-tainted              22.1 MiB
 kmod-nvidia-open-6.17.10-200.fc42.x86_64               x86_64       3:580.105.08-1.fc42                                      @commandline                          617.9 MiB
 kmod-nvidia-open-6.17.11-200.fc42.x86_64               x86_64       3:580.119.02-1.fc42                                      @commandline                          619.1 MiB
 kmod-nvidia-open-6.17.13-200.fc42.x86_64               x86_64       3:580.119.02-1.fc42                                      @commandline                          619.2 MiB
Removing unused dependencies:
 gcc-c++                                                x86_64       15.2.1-5.fc42                                            updates                                41.4 MiB
 libstdc++-devel                                        x86_64       15.2.1-5.fc42                                            updates                                16.1 MiB

Transaction Summary:
 Removing:           6 packages

After this operation, 2 GiB will be freed (install 0 B, remove 2 GiB).
Is this ok [y/N]: y
Running transaction
[1/7] Prepare transaction                                                                                                            100% |  21.0   B/s |   6.0   B |  00m00s
[2/7] Removing akmod-nvidia-open-3:580.119.02-1.fc42.x86_64                                                                          100% | 200.0   B/s |   2.0   B |  00m00s
[3/7] Removing kmod-nvidia-open-6.17.13-200.fc42.x86_64-3:580.119.02-1.fc42.x86_64                                                   100% |   0.0   B/s |   7.0   B |  00m07s
[4/7] Removing kmod-nvidia-open-6.17.11-200.fc42.x86_64-3:580.119.02-1.fc42.x86_64                                                   100% |   0.0   B/s |   7.0   B |  00m07s
[5/7] Removing kmod-nvidia-open-6.17.10-200.fc42.x86_64-3:580.105.08-1.fc42.x86_64                                                   100% |   0.0   B/s |   7.0   B |  00m07s
[6/7] Removing gcc-c++-0:15.2.1-5.fc42.x86_64                                                                                        100% |   2.6 KiB/s |  66.0   B |  00m00s
[7/7] Removing libstdc++-devel-0:15.2.1-5.fc42.x86_64                                                                                100% |   2.6 KiB/s | 937.0   B |  00m00s
Complete!
jojo@waldstadion:~$ akmod --from-init
bash: akmod: command not found...
Similar command is: 'kmod'
jojo@waldstadion:~$ 

Should I try to use kmod or try to install/find akmod? I am not familiar with kmid/akmod


You got that error from misspelling, the command is “akmods” not “akmod”.
But even with “akmods” there is no such argument --from-init so I’m not sure what you’re doing there.

UPDATE edit— I looked in the “akmods” script and there is a “–from-init” option in the code it’s just not shown when you run “akmods --help”. So my “no such option” statement above was wrong. I was just saying there was no such option because I didn’t see it from the “akmods --help” output.
Which is BAD. In fact the --help doesn’t show several different valid options in this list

–from-init
–from-posttrans|–from-kernel-posttrans|–from-akmod-posttrans

I’ve posted a bug for that: 2426708 – akmods --help doesn't show all options

1 Like

The akmods.service, which would normally run at boot time, would normally remove the files from /var/cache/akmods which are no longer related to any installed kernels.

1 Like

I would expect the dnf removes would have done cleanup already. I would expect the dnf removes would have done cleanup already.

dnf doesn’t do anything to /var/cache/akmods/* area other than possibly reading the newly built kmod-<name>-<kversion>-<packageversion> rpm files from there to install them after akmods builds them. As far as “dnf remove”, dnf is clueless about the /var/cache/akmods/ area.

1 Like

dnf removes did not clear /var/cache/akmods. akmods.service is up and running.
I will wait and see what happens after I have rebuilt new kernels.

Thank you all for your hints ans support!

Could you pls provide output of ls -l /var/cache/akmods/nvidia-open ?
I am very interested why there is such a huge difference in space used. I’d expect the resulting and cached rpm files to be similar in size compared to the cached files in /var/cache/akmods/nvidia.
So it seems that something else is stored there as well, the object files?

akmods has a cleanup_cachedir function that supposed to run during a system start. But it looks like it’s not doing its job. I have rpms that are ca. 3 months old.

cleanup_cachedir ()
{
	local excluded
	excluded=$(find /boot -name 'vmlinuz-*' '!' -name '*rescue*' 2>/dev/null | sed 's/.*vmlinuz-//')
	local -a file_list
	mapfile -t file_list < <(find /var/cache/akmods -mindepth 3 2>/dev/null | grep -Fv -f <(echo "${excluded}"))
	for one_file in "${file_list[@]}"; do
		if grep -q ".*\.rpm$" <<< "${one_file}" ; then
			if ! rpm -q "$(basename "${one_file%.rpm}")" >/dev/null ; then
				rm -f "${one_file}"
			fi
		else
			rm -f "${one_file}"
		fi
	done
}

[deleted]

# first parse command line options
while [ "${1}" ] ; do
	case "${1}" in

[deleted]

            --from-init)
			# just in case: remove stale lockfile if it exists:
			rm -f /var/cache/akmods/.lockfile
			# Clean old logs and rpm files from no more installed kmod
			# packages.
			cleanup_cachedir
			# akmods --from-init only operates on current kernel
			kernels="$(uname -r)"
			shift
			;;