technology, keyboard, computing-785742.jpg

How to fix Linux Mint stalling while removing all DKMS modules during updates

While attempting to update my Linux operating system via terminal the update got stuck/hung on the following line: ‘Removing all DKMS modules’. This tutorial mainly describes how to fix the problem of Linux getting stuck at the line ‘Removing all DKMS modules’ while running a system update. This post will also describe how to fix problematic packages causing that issue, in my case NVIDIA DKMS and driver packages.

I had to abort the update process using ‘CTRL + C’ after my system would just sit at the line ‘Removing all DKMS modules’. After I canceled updates, I attempted to run this command as a fix:

sudo dpkg --configure -a

This resulted in the error: ‘dpkg frontend is locked by another process’. In order to remove the lock I had to run the following two commands until I no longer received the ‘locked’ error:

sudo rm -v /var/lib/dpkg/lock
sudo rm -v /var/lib/dpkg/lock-frontend

Running ‘sudo dpkg –configure -a’ after this resulted in discovering the following two errors:

dpkg: error processing package nvidia-driver-390 (--configure):
 dependency problems - leaving unconfigured
dpkg: error processing package nvidia-dkms-390 (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Errors were encountered while processing:
 nvidia-driver-390
 nvidia-dkms-390

I forced the removal of the problem NVIDIA driver package:

sudo dpkg --remove --force-remove-reinstreq nvidia-driver-390

I also attempted to force the removal of the problem NVIDIA DKMS package:

sudo dpkg --remove --force-remove-reinstreq nvidia-dkms-390

However, this command also resulted in getting stuck on the line ‘Removing all DKMS modules’ so I had to execute ‘CTRL + C’ again to abort.

I executed the following command from earlier with no problems this time:

sudo dpkg --configure -a

I then ran the following command:

sudo apt -f install

The output showed various errors, and so because I was not sure what the status of nvidia-dkms-390 was, I tried reinstalling it:

sudo apt install nvidia-dkms-390 --reinstall

This result was successful. I subsequently decided to make sure I had the latest updates, then uninstall the NVIDIA driver and DKMS packages so I could reinstall them and make sure everything was corrected and cleaned up.

sudo apt update
sudo dpkg --remove --force-remove-reinstreq nvidia-driver-390
sudo dpkg --remove --force-remove-reinstreq nvidia-dkms-390

I instructed dpkg to again correct any potential problems:

sudo dpkg --configure -a

I reinstalled the NVIDIA DKMS and driver packages:

sudo apt install nvidia-dkms-390 --reinstall
sudo apt install nvidia-driver-390 --reinstall

I checked for updates related to display drivers, and seeing none, I ended troubleshooting here. I also launched the Driver Manager in Linux Mint to verify that the NVIDIA driver was showing up and selected, which it was.

As a final step as well as to check that everything was resolved, I ran another update (successfully this time) with the following commands:

sudo apt update
sudo apt upgrade

The update was successful, with my system gaining the latest updates and the issues with removing DKMS modules and problematic packages resolved.

Leave a Comment

Your email address will not be published. Required fields are marked *