Running VirtualBox at boot up?

Now that Systemd is the approved startup mechanism in 13.1, can anyone advise on (or point to) a sample script to place in /etc/systemd/user/?
I would like a VirtualBox VM to run without having to login to start it (either manually or via Autostart script folder)

Regards, Martin

The openSUSE package has it’s own startup script also the vbox package from vbox.org.
You can also search for systemd-vboxinit in the repos.

Hi Jason,

Thank you for the pointer…
However, not being all that bright, I’m going to need some more help! For example, you say:

Does that mean that if I installed VirtualBox from openSUSE, there will be functions that are not included when I install from the Oracle site?

Secondly, I have downloaded (but not installed) your package as mentioned below:

You can also search for systemd-vboxinit in the repos.

And again, looking at the scripts and readme files, I recognise that I’m out of my depth! Do you have any step-by-step instructions?
I had hopped to learn gently by trying some of the given commands. For example the manual (./usr/share/man/man1/systemd-vboxinit.1.gz) says under the heading “USING VBOXMAGE”:

VBOXManage list vms

On my system (SUSE 13.1, VirtualBox 4.3.16) I get a null return? No error message but also no report of my functioning VM either?

I know that you were trying to be helpful, and now I am peppering you with more questions. But any advice will be most welcome.

Best regards, Martin

Yes the openSUSE package and the Oracle package has its own startup script, some where in /etc/init.d

VBoxManage list vms

It will return nothing if you don’t have any vms configured. No useful exit status either :\

You can read that man page without installing the package.

man ./systemd-vboxinit.1.gz

Of course you have to be in the same directory where that compressed man page is ;).

Okay, Jason, I understan that. And I am sure that it is doing its stuff and starting the management infrastructure to enable a VM to run…

myNewRouter:~ # cat /var/log/boot.log | grep VirtualBox
         Starting LSB: VirtualBox Linux kernel module...
  OK  ] Started LSB: VirtualBox Linux kernel module.
         Starting LSB: VirtualBox watchdog daemon...
         Starting LSB: VirtualBox autostart service...
         Starting LSB: VirtualBox web service API...
  OK  ] Started LSB: VirtualBox watchdog daemon.
  OK  ] Started LSB: VirtualBox autostart service.
  OK  ] Started LSB: VirtualBox web service API.
myNewRouter:~ # 

But what I can’t understand is how do I flag/command my working VM to start before I log in?
For example, at the moment, I have the following script (which works) but of course I need to log in as “myUser” to invoke it.

myNewRouter:~ # cat /home/myUser/.kde4/Autostart/mailhost.desktop
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=mailhost
Comment=Starts the VirtualBox machine mailhost
Type=Application
Exec=/usr/lib/virtualbox/VirtualBox --comment "mailhost" --startvm "45fded79-f40a-4d62-b912-3ea0593379c0"
Icon=virtualbox-vbox.png
myNewRouter:~ # 

Do I have to tell the vbox* scripts in /etc/init.d/ which VM I want to run at boot. Or do I somehow flag the VM, so that the vboxautostart-service will find and start my VM?

Looking forward, to you advice, Martin

Im not sure if *.desktop file is useful in ~/.kde4/Autostart, i did however placed a script in there and it works.

This is how some folks manage to use the autostart service from Oracle package. I had done it once but i don’t remember now. You have to configure/edit some config files.

http://lifeofageekadmin.com/how-to-set-your-virtualbox-vm-to-automatically-startup/

This is how the Arch Linux folks do it.

https://wiki.archlinux.org/index.php/VirtualBox#Starting_virtual_machines_with_a_service

As for the openSUSE package i have never used the /etc/init.d/vboxes to be honest.

Last but not the least i have my own way of doing it with systemd :).

That is not the way you handle a vm using the cli, it is

VBoxManage

of

vboxmanage

but not

Virtualbox

or

virtualbox

Yes VirtualBox or virtualbox is the name of the package but it is just the GUI interface to the vms inside the package.

But this is the correct syntax.

VBoxManage startvm VMNAME --type WHATEVER-TYPE-YOU-LIKE

I suggest you learn the syntax first before you create any automation with your vms.:wink: