Ubuntu – Safely close virtualbox machine on host reboot

rebootvirtualboxwindows 7

I'm running Windows 7 inside Virtualbox on Ubuntu 11.10. Everything works fine. I'm running it at startup, but I have a problem with rebooting.

When I type sudo reboot now the state of the virtual Windows 7 isn't saved. After the reboot the virtualbox starts, but instead of the running Windows I get the Windows' 7 crash boot menu and the windows is booting again.

Is there an option that Ubuntu could send some signal to the virtual box to safely close the instance before the host reboot?

Best Answer

In case you really need to shutdown while a virtual machine in Virtual Box is running you could define your own script for a manual shutdown where you place a command to save the machine state before the shutdown process starts:

VBoxManage controlvm <name> savestate # <name> is the name of your VM
gnome-session-quit --power-off # this example displays the power-off dialog for >11.10

Alternatively you could also generate a script that always runs at shutdown.