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