Ubuntu – Removing Virtualbox-5.1 in a stuck state

uninstallvirtualbox

I am not new to linux and have had to face the occasional odd package or install situation but this tops all of them. At this point I just want to kill it with fire!

I have Virtualbox-5.1 in a somewhat messed up state. It seems something went wrong when i tried to upgrade to it a couple of months back and I never bothered to investigate.
Ever since trying to install it I get error messages every time I upgrade packages. To be specific:

Running VMs found

VirtualBox is currently running. Please close it and try again. Please note that it can take up to ten seconds for VirtualBox (in particular the VBoxSVC daemon) to finish running.

Now I did the usual ps -aux | grep vbox and ps -aux | grep virtualbox and I can assure you, no vbox processes are running.

I also checked /tmp for any lock files which should be named '.vbox-username-ipc'. It is not there.

I have no idea how i got my system in this state but I would very much like to remove virtualbox without having to reinstall. Any input ?

Best Answer

I had the same problem, but just a little bit differently. I tried to reinstall virtualbox (switching from distro to official release) and it failed to uninstall, so I could not remove or install the new copy. I managed to fix the issue by creating an empty file: /usr/lib/virtualbox/prerm-common.sh

Edit: Make the file executable with chmod +x /usr/lib/virtualbox/prerm-common.sh

Then running sudo apt-get remove virtualbox

Related Question