Working with several Vagrant boxes in parallel can be tricky. So today I wrote a small shell script to help me here. It will
- start the VM (if not already running),
- Login into the VM via SSH,
- suspend the VM after exiting the VM (if you want)
if [ -f ./Vagrantfile ]
if vagrant status | grep -q "running ("
echo Box is already running
echo Starting box ...
echo Login in ...
read -n1 -p "Suspend box ? [y,N]" doit
case $doit in
y|Y) vagrant suspend ;;
n|N) echo OK ;;
*) echo OK ;;
echo No Vagrantfile found!
After some time a restarted playing around with my private vagrant setup when i came across this message, after trying to “up” my machines:
Your VM has become “inaccessible.”
So my setup is broken and I had to repair the machines. Luckily this is very easy:
$ vboxmanage list vms
There you can see the inaccessible vm and its id. Just unregister it and vagrant will be able to bring up your system from scratch.
$ vboxmanage unregistervm 652819f9-a4c4-4b18-b7e0-ea8e8bcec828
$ vagrant up
Bringing machine 'centos' up with 'virtualbox' provider...
[centos] Importing base box 'centos'...