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

前端 未结 4 1397
忘掉有多难
忘掉有多难 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.

提交回复
热议问题