Howto autostart and shutdown virtualbox machines gracefully with host shutdown – Lubuntu

Hi,

recently I have encountered problem how to shutdown virtual machines when host machine I shutting down. There are many script solutions out there, but the simplest is to use Lubuntu virtualbox package. Then in /etc/default/virtualbox You have to add these to lines at the bottom of the file:

SHUTDOWN_USERS=”user names separated by space”

SHUTDOWN=”savestate”

 

Remember that if You are using remote desktop and try to shutdown with acpibutton, then windows warning message will prevent windows from closing system gracefully!

Add those entries to /etc/default/virtualbox:

VBOXAUTOSTART_DB=/etc/vbox
VBOXAUTOSTART_CONFIG=/etc/vbox/vbox.cfg

create folder /etc/vbox and inside create file /etc/vbox/vbox.conf:

default_policy=allow

Change permissions to the folder:

chgrp vboxusers /etc/vbox

chmod 1777 /etc/vbox

— AUTOSTART VIRTUAL MACHINES —

To start on boot You have to add:

VBoxManage modifyvm VM-name –autostart-enabled on –autostart-delay 1

Autostart script can be found here https://raw.githubusercontent.com/mdaniel/virtualbox-org-svn-vbox-trunk/master/src/VBox/Installer/linux/vboxautostart-service.sh

If You dont have it download to /etc/init.d and then set 755 permission and add to boot order:

update-rc.d vboxautostart-service.sh defaults 99 01

 

PROBLEMS WITH LUBUNTU AND VIRTUALBOX 4.3.14

I have found only solution to start at boot, dirty but working, add to /etc/rc.local:

/bin/sleep 30
sudo -H -u s0 /usr/lib/virtualbox/VBoxHeadless –startvm s0l-winxp –vrde off &

Funny think that sleep is crucial trick here 😛

USB DEVICES

You need extension pack plus You have to add user to vbox group:

usermod YourUserName -a -G vboxusers

Use:

VBoxManage list usbhost
to list usb devices that virualbox can see.

To allow access to com port tty do following:
usermod YourUserName -a -G dialout

 

 

Sorry for dirty article, but i don`t have time to write it properly now. I just wanted to share my frustration and solution with the world 😀

 

Comments are closed.