Removing Virtualbox-5.1 in a stuck state

15,944

Solution 1

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

Solution 2

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
    

Solution 3

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.

Solution 4

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
Share:
15,944

Related videos on Youtube

Klaus Steinhauer
Author by

Klaus Steinhauer

I have been using computers since the age of 8 and Linux for about 7 Years now. I currently work as an administrator for a small 20 client office mostly using Linux machines and several Servers. I'm also working on getting my bachelors degree in CS/Business

Updated on September 18, 2022

Comments

  • Klaus Steinhauer
    Klaus Steinhauer almost 2 years

    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 ?

    • Takkat
      Takkat almost 8 years
      That message should be displayed only if a running VBoxSVC process was detected. Please check again and also take care of appropriate capitals.
    • Klaus Steinhauer
      Klaus Steinhauer almost 8 years
      no matter the capitalization, no prozess containing "VB", "vb" or "virutalbox" is running.
    • Takkat
      Takkat almost 8 years
      That's weird... the virtualbox code responsible for this message checks for pidof VBoxSVC. There is a single report of erroneous settings in /etc/vbox in virtualbox forums but I can't reproduce this.
    • Klaus Steinhauer
      Klaus Steinhauer almost 8 years
      I hadn't found that thread before. But: the directory is empty.
    • Chan Kim
      Chan Kim about 4 years
      in my case, I tried ps -eax | grep vbox and found there was a process running (I forget, something like vboxSM?..) so I killed it, and did 'sudo apt remove virtualbox-6.1' to remove it.
  • Klaus Steinhauer
    Klaus Steinhauer over 7 years
    brilliant! Thank you so much! after creating that file and chmod +x the removal finally worked!
  • TheBat
    TheBat over 7 years
    Glad it worked for you too!
  • DevonDahon
    DevonDahon over 6 years
    That's the perfect answer.
  • wunderdojo
    wunderdojo almost 5 years
    That was the only thing that worked for me after a ton of hair pulling. Thanks!
  • qamnott
    qamnott about 3 years
    That really helped with my case.