This assumes that you are the only user on your system if not then you can try my Phpvirtualbox guide. You do not need your favorite sudo utility nor running su just to set your vms to auto. Enable the systemd service one time and use VBoxManage to set your vms to auto.
Download the script that will handle the vms.
- wget https://raw.github.com/Jetchisel/VBoxAutostart/master/systemd-vboxinit
- cp -v systemd-vboxinit ~/bin
- chmod ug+x ~/bin/systemd-vboxinit
Change the group to vboxusers
- chgrp vboxusers ~/bin/systemd-vboxinit
2. Download the unit file that will execute your script during boot/restart/shutdown of the host.
- wget https://raw.github.com/Jetchisel/VBoxAutostart/master/VBoxAutostart@.service
- cp -v VBoxAutostart@.service /usr/lib/systemd/system
- systemctl start VBoxAutostart@your-user-name.service
- systemctl enable VBoxAutostart@your-user-name.service
- systemctl status VBoxAutostart@your-user-name.service
3. Choose your vms that you want to autostart and autosave during boot/restart/shutdown of your host.
Get the names of the vms.
- VBoxManage list vms
- VBoxManage setextradata YOUR-VM-NAME pvbx/startupMode auto
- VBoxManage getextradata YOUR-VM-NAME pvbx/startupMode
- VBoxManage setextradata YOUR-VM-NAME pvbx/startupMode manual
- VBoxManage setextradata YOUR-VM-NAME pvbx/startupMode
- You can use the ExtraData script from the zip file below to manage your vms.
4. To access your vms.
- rdesktop localhost:1234
where 1234 is the port number which you can set via the gui or via VBoxManage.
A gui app which you can use is krdc for Kde and gnome-rdp for Gnome.
The zip file from github. https://github.com/Jetchisel/VBoxAutostart/archive/master.zip
I have package this stuff and it's in OBS now as an rpm. Look for systemd-vboxinit
NOTE: if you have the Phpvirtualbox solution then you do not need this thus it can conflict with each other.