Run your virtual OS directly from GDM in Ubuntu
If you regularly run a couple of OS from your VirtualBox and want to login to those OS directly from GDM session, here is a quick way to do it. For this to work you should have already set up your VirtualBox. Here we won’t be talking about how to setup VirtualBox but only how to login to a virtual OS from GDM session.

- Windows XP GDM
1. Create a bash script with the following contents
#!/bin/bash
VirtualBox -startvm NameOfYourVirtualOS
Replace yourSUPassword with your password, and NameOfYourVirtualOS with the name that you have given to your virtual OS in VirtualBox.
2. Name it something like windowsXPGDM (if you want to run Windows XP), make it executable, and then copy it to /usr/bin.
$ chmod 755 windowsXPGDM
$ sudo cp windowsXPGDM /usr/bin
2. Go to /usr/share/xsessions and create a new file with the following contents:
[Desktop Entry]
Encoding=UTF-8
Name=WindowsXP
Comment=My Virtual WindowsXP
Exec=/usr/bin/windowsXPGDM
Icon=
Type=Application
3. Save it with a name something like windowsXP.desktop.
4. Log out and you will see a new entry WindowsXP in your GDM session. You can now directly open VirtualBox session without even logging in to your Ubuntu machine.
Related posts:
lapubell Says:
but isn’t the point of the virtual machine to have your xp (or whatever) installation accessible in sync with your regular desktop?
cool tutorial though. if i have to fix a windows computer again, I might want to do something like that.
does this return to gdm when you shut the virtual machine down?
Posted on October 14th, 2008 at 10:53 am
Dave K Says:
Very interesting tutorial, thanks!
Seems like it will pose a security risk tho, putting your password in a plain text file.
Posted on October 14th, 2008 at 2:17 pm
Daeng Bo Says:
I’m pretty sure you mean to put your login name, not your password, into “su” because “su username” will change the session to “username.”
NAME
su – change user ID or become superuser
SYNOPSIS
su [options] [LOGIN]
DESCRIPTION
The su command is used to become another user during a login session.
I’m not sure why you’d need this, though. Can you elaborate? I thought the login session would already be run as the user GDM logged in with.
Posted on October 15th, 2008 at 4:17 am
ashokgelal Says:
@Daeng Bo: Thanks for pointing that out. I don’t know what came to my mind to include password after su. That’s ridiculous! It doesn’t need any password or username.
Posted on October 15th, 2008 at 10:06 am
ashokgelal Says:
@Dave K: I’ve updated the post, you don’t need to put any password or username.
Posted on October 15th, 2008 at 10:07 am
weizbox Says:
‘chmdo 755 windowsXPGDM’
should be
‘chmod 755 windowsXPGDM’
chmod, not chmdo.
Good thing you took out the ’su’ part in the windowsXPGDM file, that was pretty reckless.
As well, this has nothing to do with Ubuntu specifically, so why did you title the article as such? Don’t you think this gives a misguided view to newcomers to Linux when you say something is for a specific distro, when it’s not?
Posted on October 15th, 2008 at 2:05 pm
iUbuntu Says:
Don’t worry about Typos. U r right about Ubuntu though, why people love putting Ubuntu in their title? Just look at my nickname – iUbuntu. I guess there are many reasons: simply because it works great, the no. of users adopting Ubuntu is increasing so it’s all about attracking traffic, Ubuntu has won best Linux desktop distro, this post author has tested this tip only in Ubuntu and Ubuntu is just so cool! I suggest you to better change your name to weizboxubuntu and change your Digg profile picture to something other than Gentoo.
Posted on October 15th, 2008 at 2:59 pm
weizbox Says:
lol. best satire ever
Posted on October 15th, 2008 at 3:32 pm
Clifford Says:
Very nice. I was thinking about how to do this last week for my older computer. That way I could have the virtualbox without the overhead of a desktop while not having to dualboot.
Thanks
Posted on October 16th, 2008 at 12:31 am
Aronzak Says:
Great tip. What would be really nice is if virtualbox was initialised at bootup, and could start quickly. Then you could realistically replace Windows boxes with Linux (except for graphical apps).
Posted on October 16th, 2008 at 1:46 am
Virtual machines na sesion GDM. : WIKI.LUCANUSCERVUS.ORG.UK Says:
[...] Quick Tweaks atopei o seguinte post pra empregar unha maquina virtual directamente dende o comenzo con GDM en [...]
Posted on October 16th, 2008 at 2:47 am
harpazo Says:
Can you do the same for VMWare? If so, what are the commands?
Thanks so much!
Posted on October 16th, 2008 at 6:21 am
Stomfi Says:
I am thinking that the user chooser would be a better place to put the choices since one is not logging into one’s normal session. In that way the user would be presented with an immediate menu rather than have to select from the session selector.
Could have a password using this method to add some security. The user name would be XP or whatever.
Have to figure out how to do this as I use Virtualbox to run all the other Linuxes under Ubuntu.
Posted on October 17th, 2008 at 6:47 am
Stomfi Says:
On second thoughts the easy way (ie using this idea) is to create a user for each virtual box.
If you run VirtualBox as a user you may have to run Virtualbox for each user to create the required VM in their name and folder so it gets found.
Create a GDM Xsession entry (or if you are using KDM an /etc/X11/wmsession.d) entry for each VM and on second login select the session for the VM user name.
I used the command VBoxSDL -vm to minimise resources even more.
Thanks for a handy tip.
Posted on October 17th, 2008 at 8:42 pm
ashokgelal Says:
@Stomfi: Great Idea! I was also trying to figure out if it was possible? Did it work for you? If yes, would you please explain it step-by-step and I will be more than happy to write a post mentioning you as a contributor.
Posted on October 17th, 2008 at 8:52 pm
Neal Stone Says:
I did this tip and it worked just fine. great in fact. As for security, I still had to enter my login and password at the GDM screen.
Posted on October 17th, 2008 at 11:21 pm
Neal Stone Says:
Ignore the part about the password that is lined out. You only need this part:
#!/bin/bash
VirtualBox -startvm NameOfYourVirtualOS
FOllow the rest of the instructions and it works well. The main reason to do a VM this way is you don’t have the Gnome or KDE graphical interface using up resources and the system, runs better.
There is an addon that you can install with VirtualBox that contains additional drivers. I had issues with the mouse lsoing the VM until I installed the addon.
Posted on October 18th, 2008 at 6:33 pm
Amit Says:
Hey,
Thanks for the nice tip
It works on Ubuntu 8.10 Beta
Thanks again,
Amit
Posted on October 22nd, 2008 at 12:38 am
calito Says:
to comment on the idea for a virtualbox os for each user i did this to make it so you dont have to enter a password
sudo passwd -d your_username
sudo sed -i ’s/#PasswordRequired=false/PasswordRequired=false/’ /etc/gdm/gdm.conf
sudo sed -i ’s/nullok_secure/nullok/’ /etc/pam.d/common-auth
and after that you should be able to login without entering a password which can get tedious when switching between users. of course dont do this if your concerned about security and dont trust people in your house
and on another note you must make sure the .Virtualbox directory has sufficient permissions if your sharing it between users.
Posted on November 10th, 2008 at 11:32 am
Shaarangapanaye Says:
Wow! Thank you! I always wanted to write in my site something like that. Can I take part of your post to my blog?
Posted on March 1st, 2009 at 6:46 am
Run your virtual OS directly from GDM in … « Standalone Complex – Final Gig Says:
[...] http://www.quicktweaks.com/2008/10/14/run-your-virtual-os-directly-from-gdm-in-ubuntu/ [...]
Posted on July 22nd, 2009 at 6:23 am
Linfiniti Geo Blog » Blog Archive » Some handy resources for thin clients and virtual machines Says:
[...] VM from GDM – This one explains how to set up a custom session type so that it logs you directly into a virtual machine instance from the Gnome Display Manager. So you get a full screened windows or whatever session with no Gnome running in the background. [...]
Posted on August 23rd, 2009 at 4:06 am
Alice Dudson Says:
Very nice looking blog
Posted on November 7th, 2009 at 8:16 pm