This is a handy tip if you want to run a virtualbox server but dont want to have to login in as your user to run it or you want to reduce overhead on the host whilst using virtualbox. In this example Im using debian for both the host and guest and lightdm as the login manager, but setting this up should be very similar on other distro’s and login managers.
The first step is to make a small script to start the existing vm it, it should look like
VirtualBox –startvm ‘Debian’
If your unsure of the name you can find out by using VBoxManage list vms. Make sure you save that in /usr/bin/ Im using /usr/bin/debian-vbox-session make sure you also make the script executable and has 755 perms, this can be done with sudo chmod +x /usr/bin/debian-vbox-session && sudo chmod 755 /usr/bin/debian-vbox-session if you called the script something else obviously change debian-vbox-session to what yours is.
Next step is to create a launcher for your display manager should look similiar to
Save it to /usr/share/xsessions/ so for me I am saving it as /usr/share/xsessions/debain-vbox. Now if you logout there should be an options under ‘sessions’ for Debian. Keep in mind that only your user would have access to virtual machine so other users will not be able to log into a virtualbox session unless you give them access or create another virtualbox session for them to login as.