I am using the vboxautostart-service to start all my vms on system boot (Debian 7), they've been configured with this command: VBoxManage modifyvm '<vm-name>' --autostart-enabled on --autostop-type savestate.

I can also stop them manually by executing service vboxautostart-service stop, this takes about 10 seconds to save state for all vms.

However, if i reboot the host machine (ctrl+alt+del or executing reboot) it won't wait for the vm's to save their state, and next time I boot up they all have the state Aborted. I tried modifying the vboxautostart-service by adding a sleep 15, but to no effect. The processes seem to get killed off, I suppose because they don't exit fast enough.

Does anyone know how to work around this?


Long story short... you need to write your own init.d script to run on run-levels 0(halt) and/or 6(reboot) and perhaps run-level 1 (single-user-mode, typical for recovery situations).

For example, in /etc/init.d/virtualbox, create something like this:


# Provides:          virtualbox_start_and_stop
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: 
# Description:       Start virtualbox on boot, and shutdown safely on shutdown/reboot.

case "$1" in
    echo "Starting Virtualbox "

    # Do whatever to start or resume your virtualbox instances.
    # Perhaps look for a txt file someplace with VMs that need to be restarted or resumed... then start 'em.
    echo "Stopping Virtualbox"

    # Do something to either shutdown or savestate your virtualbox instances.
    # maybe also save the instances that should be resumed into a txt file someplace for the start method above.

    echo "Usage: /etc/init.d/virtualbox {start|stop}"
    exit 1

exit 0

Make sure it's executable (chmod +x /etc/init.d/virtualbox) and then run update-rc.d virtualbox defaults to create all the appropriate symlinks in the correct places to start/stop correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.