ruebenramirez / blog

My blog
http://blog.ruebenramirez.com/
7 stars 0 forks source link

managing virtualbox VMs via the CLI #387

Open ruebenramirez opened 7 years ago

ruebenramirez commented 7 years ago

an interesting thing happened...I started a vagrant VM accidentally, and realized I needed to make some more changes....so ctrl+c'd out of the startup.

The next time I attempted to startup the vagrant VM, I got this

$ sudo vagrant destroy -f && sudo vagrant up
==> default: VM not created. Moving on...                                                                      
Bringing machine 'default' up with 'virtualbox' provider...                                                    
==> default: Importing base box 'newtek-shop-10'...                                                            
==> default: Matching MAC address for NAT networking...                                                        
==> default: Setting the name of the VM: simple-magento-vagrant                                                
The name of your virtual machine couldn't be set because VirtualBox                                            
is reporting another VM with that name already exists. Most of the                                             
time, this is because of an error with VirtualBox not cleaning up                                              
properly. To fix this, verify that no VMs with that name do exist                                              
(by opening the VirtualBox GUI). If they don't, then look at the                                               
folder in the error message from VirtualBox below and remove it                                                
if there isn't any information you need in there.                                                              

VirtualBox error:                                                                                              

VBoxManage: error: Could not rename the directory '/root/VirtualBox VMs/simple-magento-vagrant_1487903353455_36
79' to '/root/VirtualBox VMs/simple-magento-vagrant' to save the settings file (VERR_ALREADY_EXISTS)           
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SessionMachine, interface IMachine, c
allee nsISupports                                                                                              
VBoxManage: error: Context: "SaveSettings()" at line 2992 of file VBoxManageModifyVM.cpp

so it looks like this /root/VirtualBox VMs/simple-magento-vagrant_1487903353455_3679 directory was just left over and vagrant didn't know to destroy it on the next start?

manual cleanup

List out the virtualbox VMs:

$sudo vboxmanage list vms
"simple-magento-vagrant_1487903271872_17620" {a789e828-c54f-4d30-a6ef-1b6586dd637c}                            

delete the offending VM manually:

$ sudo vboxmanage unregistervm "simple-magento-vagrant_1487903271872_17620" --delete                                                                                                          
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%