55

During a recent apt-get dist-upgrade of 12.10 I received the following error:

Setting up linux-headers-3.5.0-19-generic (3.5.0-19.30) ...
Examining /etc/kernel/header_postinst.d.
run-parts: executing /etc/kernel/header_postinst.d/dkms 3.5.0-19-generic /boot/vmlinuz-3.5.0-19-generic
Error! Could not locate dkms.conf file.
File:  does not exist.

Any ideas?

1
  • I know this is a bad answer, but I always have that error, and things work fine. I guess dkms just uses default settings.
    – MiJyn
    Dec 9, 2012 at 20:28

5 Answers 5

47

This is usually caused by modules in /var/lib/dkms that don't have a dkms.conf file within their source subdirectories - dkms expects this file, so will report an error if it's missing, and then may miss out on compiling some valid modules.

To find the offending module, run this short script (thanks to Lekensteyn):

for i in /var/lib/dkms/*/[^k]*/source; do [ -e "$i" ] || echo "$i";done

That will output any dkms module directories; you can then decide whether to uninstall the package that created them, or if they've been manually installed or renamed, to move them somewhere else or remove them.

4
  • 3
    Perfect. The other answers may apply to specific instances, but this very quickly demonstrated where the issue was (and it was really a non-issue, as certain software was copying old installations to a /var/lib/dkms/*.old directory).
    – Auspex
    Dec 29, 2015 at 17:31
  • In case nvidia is the offender e.g. /var/lib/dkms/nvidia/396.24/source is the output, check there are already newer versions in /var/lib/dkms/nvidia and remove the offending one.
    – Flatron
    Jul 17, 2018 at 7:31
  • Thanks! In my case the offender was open-vm-tools packages, and after purging I had to remember to run apt auto-remove, as a dependency was causing this problem. Nov 12, 2019 at 19:50
  • for me the package was evdi Mar 4 at 21:31
36

I've been getting that on kernel upgrades for a while, with the result that not all of my dkms drivers get updated on kernel-upgrades.

Firstly I was able to workaround the problem by reconfiguring any packages that used dkms to force them to be recompiled for the current kernel - eg it was my AMD video drivers that failed (package == fglrx):

sudo dpkg-reconfigure fglrx

That would at least get the drivers configured for the current version.

Finally I found this bug, which includes some steps you can use to diagnose: https://bugs.launchpad.net/ubuntu/+source/dkms/+bug/830915

dkms status
ls -R /var/lib/dkms

Basically what they're doing is looking around for anything that is surprising, or unexpected - eg packages you have uninstalled - or software you have manually installed on an earlier ubuntu version and may not work with the newer version. Particularly check the date-stamp on the directories which might show you particularly old packages could be from manually installed packages.

ls -l /var/lib/dkms

In my case I had an old version of the fglrx install I had used to diagnose some problems a year ago and had simply re-named it. Deleting this old cruft made the problem go away.

If there's junk delete it (or move it out of that directory) - if there's a manually installed package there, consider updating it, or uninstalling it and using the maintained version.

4
  • 1
    Thank you for this, the problem I had was with the nvidia-340 driver...
    – ionreflex
    Oct 21, 2015 at 13:52
  • 1
    I had the same issue with anbox
    – Airfield20
    Jun 9, 2018 at 12:44
  • 1
    mine problem was in vboxhost. Thanks!
    – Drey
    Dec 8, 2019 at 16:45
  • Great answer, explains how to diagnose the issue. In my case it was that in Bookworm (as Debian Testing codename) the Nvidia module started living under /var/lib/dkms/nvidia-current, and older /var/lib/dkms/nvidia/current/xxx modules werent removed - which sudo apt-get autoremove from time to time would have prevented. I always keep an old kernel for emerg, and hesitate to autoremove, but you can mark older kernel versions (or any package) as manually installed to prevent auto-removal. See: askubuntu.com/questions/779266/…
    – Rik
    Nov 16, 2021 at 1:57
16

I have had this problem with VirtualBox from Oracle's ppa, rather than the one packaged with 12.04 LTS :

Error! Could not locate dkms.conf file.
File:  does not exist.

I copied the contents of /var/lib/dkms to another directory as a backup, then removed the vboxhost directory in /var/lib/dkms;

mkdir ~/backup_dkms
cp -r /var/lib/dkms/* ~/backup_dkms 
rm -rf /var/lib/dkms/vboxhost

I then reconfigured the virtualbox package like this:

sudo dpkg-reconfigure virtualbox-4.2

and it succeeded in doing this:

   * Trying to register the VirtualBox kernel modules using DKMS
1
  • 1
    Just sudo dpkg-reconfigure virtualbox-4.2 did the job. Thank you
    – Sergey
    Jan 6, 2014 at 6:11
13

I was also suffering from this problem for a long time. I need to reinstall the NVIDIA driver each time after kernel update and restart. Recently, I started to look into this problem. Actually, my problem is that there are multiple module folders with the same prefix nvidia- under /usr/src/ and multiple folders with different version numbers under /var/lib/dkms/nvidia. After removing the older versions, both following commands

    dkms status
    dkms autoinstall

worked.

2
  • It work for me, but I had to do apt-get install --reinstall dkms and dkms autoinstall after of use your method... and then install the nvidia drivers...
    – Milor123
    Oct 4, 2017 at 3:12
  • only this solution helped - make sure to run with sudo Jan 27, 2018 at 20:37
-1

This happened to me once on a Red Hat 7.5 Workstation with an Nvidia driver. I know it's not Ubuntu but this may help someone...

Remove the Nvidia files from dkms and then reinstall dkms:

rm -rf /var/lib/dkms/nvidia
yum reinstall dkms

Then reinstall the Nvidia driver

./NVIDIA-installer.bin --dkms
reboot

WARNING, this worked for me but may not be the correct way of doing things.

1
  • 1
    And it worked for you on RedHat, not on Ubuntu !!!
    – Soren A
    Jul 25, 2018 at 7:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .