6

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

NotCras
  • 105
  • 1
  • 1
  • 10
  • Hi all, thank you for the continued answers but after the first few didn't work I solved this issue by reinstalling ubuntu and was just more careful the next time around. – NotCras Aug 18 '18 at 06:18

5 Answers5

2

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.

moiri
  • 21
  • Did not work in my machine – Ramon Suarez Jul 11 '18 at 09:05
  • This is great thanks moiri. I had previously answered a related question suggesting rebooting into insecure mode to build. I can confirm this works for the secure boot issue. I believe Ramon had a different issue, probably with dkms, that presented similarly. – Mike D Jul 12 '18 at 19:18
1

I just resolved the problem taking the following steps:

  1. Open a terminal by pressing Ctrl+Alt+T and typing:

    sudo dpkg --configure -a
    
  2. After you see the Building inital module immediately hit Ctrl+C to cancel the process
  3. Do it again for other Building modules.
  4. Reinstall VirtualBox with synaptic and reboot
  5. Go to a Terminal again and type the command:

    sudo apt install --fix-missing
    
  6. Now everything should work again.

I assume there is a major problem with VirtualBox at the moment, but everything works fine after I tested the above.

Fabby
  • 34,259
David
  • 11
0

This shows that your package manager is working:

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?

In fact it seems to build the kernel module for your kernel which, depending on your hardware, can take some time - if you do not interrupt that process like you did.

Just start again with sudo dpkg --configure -a and have a bit more patience. Then do sudo apt install -f again.

  • ok, currently running it and we will see. I will most certainly be glad if it just turns out that I'm impatient. Will post back later upon further developments – NotCras Jun 27 '18 at 06:03
  • 2
    Nope, I let it run overnight and nothing changed. No progress noted either. Thoughts? – NotCras Jun 27 '18 at 17:43
  • Since there is no error message, you might find something in the logs? You could post cat /var/log/apt/history.log | tail -n 10 and/or cat /var/log/dpkg.log | tail -n 10 – user844250 Jun 28 '18 at 22:10
  • 1
    Oh, and I found several sites that might point to your problem:

    A bug report A recommendation to uninstall and reinstall virtualbox-dkms. Maybe that will help?

    – user844250 Jun 28 '18 at 22:23
0

I had the same problem while trying to update virtualbox from apt-get.

I really don't undestand where the problem comes from, but the solution for me was to restart the computer in "insecure" mode. I mean, restart your computer, enter to BIOS setup and Disable "Boot in Secure Mode". Once the pc restarts and log into Ubuntu again, open a terminal and type sudo dpkg --configure -a. And the process wil now finish successfully.

I'm sorry I can't explain what's the reason of that problem, but I found that solutions on Google.

Hope it helps!

0

What fixed it for me was running Ubuntu's "Software Updater" in graphical mode and rebooting as it asked me to do. Terminal apt is back to normal :)

Ramon Suarez
  • 1,841