Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to start a VirtualBox VM on a separate X screen (in fullscreen) so I can switch between Linux and Windows XP by doing Ctrl + Alt + F<.

I am basically trying to do something like this:

startx "VBoxManage startvm XP" -- :4 
startx "VBoxManage startvm "XP"" -- :4 (is this correct for quotes within quotes??)

I get a "bad command line option "VBoxManage" back from the startx script so obviously I am not understanding the rules for how to write "shell magic".

How can I do this correctly, or perhaps there is a better way of achieving a VirtualBox VM on a separate X screen?

share|improve this question
up vote 1 down vote accepted

You could add something like this to your ~/.xinitrc file:

# ...
if [ "${DISPLAY}" = ":4" ]; then
  gnome-session &
  vboxmanage startvm vmname
  wait ${waitpid}
# ...

This would check if this is the display where you want to run your VM, then, start a gnome-session on background (or whatever session you want) and execute vboxmanage. The wait ${waitpid}} will keep everything running until you decide to either kill startx or exit from gnome.

share|improve this answer
Thanks a lot, I am not closing this (yet) because I would like to see if it is possible to solve this in other ways as well. :) – Waxhead Aug 30 '11 at 20:07

For anybody else who stumbles upon this...

The best way to execute commands with startx is to place them in a shell script and then use: startx ./ :4.

While this works with virtual box, vboxmanage doesn't continue running in the xsession once it has launched the virtual machine. Instead I have found virtualbox --startvm "NAME" --fullscreen actually keeps the xsession running.

share|improve this answer
virtualbox --startvm "NAME" --fullscreen is exactly what you need. – Wolfer Oct 7 '13 at 17:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.