VirtualBox – How to Safely Shutdown Guest OS Using Command Line

shutdownvirtualbox

I have Ubuntu 10.10 and using VirtualBox 3.2. As a Guest OS I have another Ubuntu in the VirtualBox.

I am starting Guest Ubuntu automatically using following command once my Host Ubuntu boots:

VBoxHeadless -startvm Ubuntu --vrdp on

Then I can access to it with ssh or tsclient.

Now I need to shutdown automatically Guest Ubuntu once I shutdown my Host Ubuntu. Does anybody know any safe method to automatically shutdown Guest Ubuntu with a command line? I have found out two ways one can shutdown Guest OS but I am not sure whether they are safe or not. Here are they:

VBoxManage controlvm Ubuntu acpipowerbutton

or

VBoxManage controlvm Ubuntu poweroff

Best Answer

If you open up Gnome Power management preferences, you can set what actions to take when the power button. If you set it to shut down, it will shut down gracefully when you press the virtual power button with the VBoxManage controlvm Ubuntu acpipowerbutton command.