Starting virtual machines during system boot

Starting virtual machines during system boot
https://forums.virtualbox.org/viewtopic.php?f=7&t=51799

Virtualbox automatic starting of VM only partially works
http://ubuntuforums.org/showthread.php?t=2204863

1.Create the file /etc/default/virtualbox

# vi /etc/default/virtualbox
# virtualbox defaults file
VBOXAUTOSTART_DB=/etc/vbox
VBOXAUTOSTART_CONFIG=/etc/vbox/vbox.cfg(註1,virtualbox.cfg)

註1:
最好更改為其它名稱
There is an error in the tutorial. The file name vbox.cfg seems to be reserved.

 

2.Now we need to create /etc/vbox/vbox.cfg file and add

# Default policy is to deny starting a VM, the other option is “allow”.
default_policy = deny
# Create an entry for each user allowed to run autostart
myuserid = {
allow = true
}

If you are the only user you can just add the line default_policy = allow to the vbox.cfg file.

 

3.Set permissions on directory to the vboxuser group and make sure users can write to the directory as well as sticky bit.

# chgrp vboxusers /etc/vbox
# chmod 1775 /etc/vbox

 

4.Add each of the users to the vboxusers group. Make sure to check their group memberships so they do not loose any groups they currently have assigned to their id.

# groups myuserid
myuserid

# usermod -G vboxusers myuserid

 

5.切換到一般使用者(su username),暫停 CGBlue

$ VBoxManage setproperty autostartdbpath /etc/vbox
$ VBoxManage modifyvm “CGBlue” –autostart-enabled on
$ VBoxManage modifyvm “CGBlue” –autostart-delay 60

$ VBoxManage modifyvm “CGBlue” –autostart-enabled on –autostart-delay 60 –autostop-type poweroff

$ vboxmanage modifyvm “CGPort” –autostart-enabled on –autostart-delay 60 –autostop-type poweroff

This will create  myuserid.start、myuserid.stop file in /etc/vbox directory

6.vboxmanage modifyvm “CGBlue” –autostop-type

VBoxManage modifyvm <Machine Name> --autostop-type savestate

The following are alternatives to savestate: [disabled|savestate|poweroff|acpishutdown].

http://unix.stackexchange.com/questions/72511/do-savestate-before-power-off-host-virtualbox-opensuse