Removing Virtualbox-5.1 in a stuck state
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
I had the same problem. I solved it by killing all the VB processes.
-
get all the processes containing VB
ps -A | grep VB
-
then kill all processes with the command
sudo kill <pid>
replace <pid>
with the process IDs of the processes you got from above command.
-
then run
sudo apt-get remove virtualbox-* --purge
You may have VirtualBox's auto-start service running. Check by running the command below.
sudo systemctl status vboxautostart-service
If it is running then stop it.
sudo systemctl stop vboxautostart-service
Then find and kill all the processes running with the commands below. (Should be about three (3))
ps -A | grep VB
sudo kill <pid>
Finally, remove and purge VirtualBox
sudo apt-get remove virtualbox-* --purge
I tried everything suggested here and anywhere else but nothing worked. It kept saying that Running VMs found. What it turned out to be in the end was the fact, that there was autostart.cfg file in /etc/vbox.
After I removed/moved this file the installation went smoothly. Hard to believe that I spent such a long time trying to resolve this.
The answer was hidden in the post Upgrade and Uninstall Failing.