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
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.

No related posts.

Spread the word, pleasssseee:
Filed under: Desktop, Linux, Software, System, Terminal, , , , , , , , , , , ,

20 Responses

  1. 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?

    Reply

    Posted on October 14th, 2008 at 10:53 am

  2. Dave K Says:

    Very interesting tutorial, thanks!

    Seems like it will pose a security risk tho, putting your password in a plain text file.

    Reply

    ashokgelal Reply:

    @Dave K: I’ve updated the post, you don’t need to put any password or username.

    Reply

    Posted on October 14th, 2008 at 2:17 pm

  3. 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.

    Reply

    ashokgelal Reply:

    @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.

    Reply

    Posted on October 15th, 2008 at 4:17 am

  4. 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?

    Reply

    iUbuntu Reply:

    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.

    Reply

    weizbox Reply:

    lol. best satire ever :)

    Reply

    Posted on October 15th, 2008 at 2:05 pm

  5. 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

    Reply

    Posted on October 16th, 2008 at 12:31 am

  6. 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).

    Reply

    Posted on October 16th, 2008 at 1:46 am

  7. 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

  8. harpazo Says:

    Can you do the same for VMWare? If so, what are the commands?

    Thanks so much!

    Reply

    Posted on October 16th, 2008 at 6:21 am

  9. 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.

    Reply

    Posted on October 17th, 2008 at 6:47 am

  10. 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.

    Reply

    ashokgelal Reply:

    @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.

    Reply

    Posted on October 17th, 2008 at 8:42 pm

  11. 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.

    Reply

    Posted on October 17th, 2008 at 11:21 pm

  12. 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.

    Reply

    Posted on October 18th, 2008 at 6:33 pm

  13. Amit Says:

    Hey,

    Thanks for the nice tip :-) It works on Ubuntu 8.10 Beta

    Thanks again,
    Amit

    Reply

    Posted on October 22nd, 2008 at 12:38 am

  14. 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.

    Reply

    Posted on November 10th, 2008 at 11:32 am

  15. 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?

    Reply

    Posted on March 1st, 2009 at 6:46 am

Leave a Reply




Comment moderation is enabled. Your comment may take some time to appear.