Ubuntu – reconfiguration issues with dpkg

aptdkmsdpkgpackage-managementvirtualbox

I ran into some problems installing a package with apt. The terminal hung up during an install and I saw no other choice but to close the terminal. The problem, however, is that I can't seem to solve the issues that this has caused.

As is typical, I get:

E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

This gets me nowhere and I'm locked out until I run sudo dpkg --configure -a. Makes sense. However, this process spits the following out and then hangs on the last line:

Setting up virtualbox-dkms (5.2.10-dfsg-6) ...
Removing old virtualbox-5.2.10 DKMS files...

-------- Uninstall Beginning --------
Module:  virtualbox
Version: 5.2.10
Kernel:  4.15.0-23-generic (x86_64)
-------------------------------------

Status: This module version was INACTIVE for this kernel.
depmod...

DKMS: uninstall completed.

------------------------------
Deleting module version: 5.2.10
completely from the DKMS tree.
------------------------------
Done.
Loading new virtualbox-5.2.10 DKMS files...
Building for 4.15.0-23-generic
Building initial module for 4.15.0-23-generic

A typical solution I've read is that you need to fix the broken packages. When I try to fix the broken packages (sudo apt install -f), the system also hangs on the same line, although the output is different:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
3 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up virtualbox-dkms (5.2.10-dfsg-6) ...
Removing old virtualbox-5.2.1

0 DKMS files...

------------------------------
Deleting module version: 5.2.10
completely from the DKMS tree.
------------------------------
Done.
Loading new virtualbox-5.2.10 DKMS files...
Building for 4.15.0-23-generic
Building initial module for 4.15.0-23-generic

I am unable to get out of it unless I kill the process. This I do by checking what is currently running related to apt (ps aux |grep apt), and then I kill the relevant processes with sudo kill -9 process_number_here.

If I try to run things after that, it tells me I still need to reconfigure dpkg.

I tried looking around for more solutions to dpkg and all I really see is the nuclear option:

sudo rm /var/lib/dpkg/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/apt/lists/lock

I also delete the files in /var/lib/dpkg/updates because when I did some digging one of the files inside had the exact same text as the above long output… but I fully admit to being out of my league here and I don't know what to do.

Taking a look at the error messages, I recognize that it hangs on building something related to the kernel. But I have no idea where to even start solving that. Any help is appreciated. My system is ubuntu 18.04

Best Answer

The system is waiting for a password in the background.

  1. Enter your root password and hit enter
  2. Enter a new password which will be used to register a Machine Owner Key (MOK) for the vboxdrv kernel module
  3. Repeat the password you entered in (2)
  4. Wait for the process to complete and reboot your system
  5. On bootup, follow the instructions to register the MOK

This did the trick for me.

Related Question