How do I destroy a VM when I deleted the .vagrant file?

前端 未结 4 1376
忘掉有多难
忘掉有多难 2021-01-29 23:14

I deleted the directory that contained the .vagrant file. When I up a new VM it\'s complaining about ports being in use. So how do I destroy a VM without having it\'s .vagrant f

相关标签:
4条回答
  • 2021-01-29 23:51

    The following bash function would poweroff and destroy all files related to all VMs for the current user:

    function killvms() {
      VBoxManage list runningvms | awk '{print $2;}' | xargs -I vmid VBoxManage controlvm vmid poweroff
      VBoxManage list vms | awk '{print $2;}' | xargs -I vmid VBoxManage unregistervm --delete vmid
    }
    

    Add it to your ~/.bash_aliases and call it in your shell via killvms.

    0 讨论(0)
  • 2021-01-30 00:02

    If you removed the VM using the GUI and you're still getting the error, you may try to delete the named VM from "%userprofile%\VirtualBox VMs". This worked for me

    0 讨论(0)
  • 2021-01-30 00:03

    Easiest thing to do is just launch the GUI client of VirtualBox and remove (possibly after shutting down) the virtual machine. You can just right click the virtual machine and perform these actions.

    enter image description here

    0 讨论(0)
  • 2021-01-30 00:13

    The following VirtualBox commands might help. If poweroff doesn't work, try unregistervm.

    $ VBoxManage list runningvms
    $ VBoxManage controlvm <uuid> poweroff
    $ VBoxManage unregistervm <uuid>
    

    Source: https://support.cloud.engineyard.com/entries/21449637-I-deleted-Vagrantfile-vagrant-and-or-the-app-directory-before-halting-the-VM-Now-ey-local-up-errors-

    Shell script to stop all running vms:

    VBoxManage list runningvms | awk '{print $2;}' | xargs -I vmid VBoxManage controlvm vmid poweroff
    
    0 讨论(0)
提交回复
热议问题