2

When I try to shutdown my machine, it "freezes" or it stays stuck on one point, where it can not complete the process. I get the message

unregistered_netdevice: waiting for vboxnet2 to become free. Usage count = 1

After some experimentation I have noticed that if I halt the vagrant boxes, this error does not happen.

vagrant halt

This is a new behaviour that started a couple weeks ago. How could I fix this?

2 Answers2

2

You'll need to setup a script to automatically run on shutdown.

See https://askubuntu.com/a/564674

Create /etc/init.d/vagrant with this content:

#!/bin/bash
vagrant global-status | awk '/running/{print $1}' | xargs -r -d '\n' -n 1 -- vagrant suspend

Make it executable and link it into the shutdown run modes:

chmod +x /etc/init.d/vagrant
ln -s /etc/init.d/vagrant /etc/rc0.d/K10vagrant
ln -s /etc/init.d/vagrant /etc/rc6.d/K10vagrant

You can test it by starting some vagrant VM's and then running the script as root:

sudo /etc/init.d/vagrant
1

Nick Breen's solution no longer works (as of October 2015, vagrant 1.4.3), as there is no longer a subcommand vagrant-status.

I used Darren Beale's one-liner in the /etc/init.d/vagrant file, and it works great:

for VM in `VBoxManage list runningvms | awk '{ print $2; }'`; do VBoxManage controlvm $VM poweroff; done
0atman
  • 119
  • 4