Configuring Virtualbox for Sharing and Mouse Control

You might have read my earlier article on installing Virtualbox in Ubuntu. I would like to explain couple of more features to use in Virtualbox. You can use these features once you install the virtualbox as explained here.

1. Sharing the folders between Ubuntu and Virtualbox Windows.

(Update: You may have to install Guest Additions as described in step 2 for sharing the folders too)

I would like to explain how to share your Ubuntu folders with Virtualbox. Thanks to Raja for the guide.

Update: If you are using the latest version of Virtualbox, you can try this instead of using the command line. Click the Settings icon in the Virtualbox window. Go to Shared Folder listed on the left side (as shown in the picture below). Click the small folder icon with a green + symbol on the right side next to Access column. Select the directory in your host OS that you want to access in the guest OS. In my case, it was the download and document directories.

Vboxshare 300x245

Click Ok. You need to install the Guest Additions as described in section 2. You can’t share folders if you don’t have guest additions installed. If you have installed it already, then start the guest OS (Windows), open My Computer, Click on Tools menu and select Map Network Drive. Select the drive letter you want under Drive: and the click Browse under Folder:. Expand VirtualBox Shared Folders as shown in the picture. Now select the directories from the list and click OK. You are all set.

Vboxshare1 300x227

If the above mentioned steps don’t work, then try this. Before you start the virtualbox, open a terminal in Ubuntu. Enter the following command:

VBoxManage sharedfolder add virtualmachinename -name “sharedfolder” -hostpath “/home/username/foldertoshare”

virtualmachinename is the name virtual machine you created. I created mine with the name WinXP.
username is your ubuntu home directory name. It’s usually /home/your user name.
foldertoshare is the name of the folder you want to share. In my case it’s Documents.
Here is the command I used.

VBoxManage sharedfolder add WinXP -name “sharedfolder” -hostpath “/home/arun/Documents”

Exit the terminal. Start the virtual OS now. Once you login to Windows, Click Start - Run and enter cmd.exe. Press Enter. You’ll get a terminal window. Enter the following command:

net use M: \\vboxsvr\sharedfolder

where M is the drive name you want to assign to the shared folder. Make sure the drive name is not used by Windows already. You will now see the shared folder as a network drive under My Computers.

2. Sharing mouse control between Ubuntu and Windows without using the control key.

If you want to share your mouse between Ubuntu and Windows (using Virtualbox) without pressing the right control key, you have to install the guest additions from the virtualbox menu. Once you start the virtual OS (Windows), press the right control key to get the mouse out of Windows control and click on Devices menu. Select Install Guest Additions (see picture below). This will install Guest Additions software in the Windows box. Once installed, reboot and login. You’ll get a warning message about the mouse control. Click OK and continue. You are all set. if you move the mouse over the virtualbox, then the control goes to virtualbox. If you move the mouse out of the box, then the control goes to Ubuntu.

Update: With the new version of Virtualbox, the installation of guest addition is not straight forward. Here are the steps to follow if your guest OS is Windows. I installed Virtualbox in Ubuntu and installed Windows XP Pro as guest OS in Virtualbox.

After you started the guest OS using Virtualbox, Click on Devices menu and select “Mount CD/DVD-ROM” and then “CD/DVD-ROM image” under that. This will show you a window as shown below. You’ll see VBoxGuestAdditions.iso listed under that. If not, you have to look under C:\Program files\Sun\xVM VirtualBox in Windows or /opt/VirtualBox-1.6.2 or /usr/share/virtualbox/ in Linux. Click that ISO file and press the select button.

VirtualBox Guest Addition

VirtualBox Guest Addition

Then in the guest OS (Windows), open My Computer and double click the CD/DVD drive. For some people, double clicking the drive itself will bring you the guest additions installation wizard. For some, it’ll show the files under that and you have to double click Virtualbox guest additions setup.exe file. This will get you the wizard. Go with the defaults and complete the wizard. Once it’s completed, you have to reboot the system. The screen resolution might change after rebooting. Go and change the resolution by right clicking on Windows desktop and selecting properties. You should now be able to move the mouse between the host and guest OSes without pressing the right control key.

Guestaddon

Technorati Tags: , , , , , ,

50 Responses to “Configuring Virtualbox for Sharing and Mouse Control”

  1. dennis parrott

    and people think i waste time reading blogs!!

    dude! your tip on how to share between VirtualBox and Ubuntu just saved me a bunch of time actually reading the manual! Sweet…

    gotta love it!! thanks!

  2. Arun

    You are welcome dennis. :)

  3. Vishal Warke

    Thanks.

  4. Vishal Warke

    Why do I keep getting following error msg after putting the command

    VBoxManage sharedfolder add WinXP -name “sharedfolder” -hostpath “/home/vishal/Documents”

    VirtualBox Command Line Management Interface Version 1.3.8
    (C) 2005-2007 InnoTek Systemberatung GmbH
    All rights reserved.

    [!] FAILED calling machine->CreateSharedFolder(Bstr(name), Bstr(hostpath)) at line 5533!
    [!] Primary RC = 0×80070057
    [!] Full error info present: true , basic error info present: true
    [!] Result Code = 0×80070057
    [!] Text = Shared folder path ‘“/home/vishal/Documents”’ is not absolute
    [!] Component = SharedFolder, Interface: ISharedFolder, {8b0c5f70-9139-4f97-a421-64d5e9c335d5}
    [!] Callee = IMachine, {fd443ec1-0009-4f5b-9282-d72760a66916}

    Could you help me in solving the problem?
    Thanks again!!!

  5. Arun

    Vishal,

    Shutdown the virtual machine completely through the shutdown option and then try issuing that command.

  6. Vishal Warke

    Thanks Arun. It worked.

  7. Will

    Hey, great tutorials, they helped out alot. But I have a problem with my mouse. I am running Ubuntu 7.04 on a Dell Inspiraon Laptop with a Logitech G5 attached. I chose the option to have the Virtualbox use that usb mouse, but when I do that, i can’t use it in Linux. I have tried to install the guest services thing, but nothing happened. If you or anyone can give me a hint I would appreciate it.

    Thanks

  8. Will

    ok, i read through the comments on your post on how to install virtualbox and found the answer. I have to turn OFF the usb mouse instead of turning it on. I mean through the settings before I start the win xp box. Anyway, it works now and everything is great. Thanks again for the great tutorials.

  9. Arun

    You got it before I could answer that. I had the same problem with my usb keyboard. Have fun.

  10. JustTech

    I have followed your instructions and thank your for them. Everything works great. It has allowed me to share a second partition on my harddrive. Only problem that I am having is that it’s not allowing me to write to the drive or change the existing on the drive. Do you know what I can do to fix this issue?

  11. Arun

    I shared a folder that was in the second partition and I could modify or create new files. I’m not sure why it’s not working for you. Did you check the file/folder permissions?

  12. Chris Gray

    Hi there, I’m having some trouble with sharing as per your instruction. My line was this:

    VBoxManage sharedfolder add xp -name <> -hostpath <>

    It doesn’t report an error, so I load VirtualBox and type:

    net use X: \\vboxsvr\shared

    It waits a while then tells me:

    System error 53 has occured. The network path was not found.

    If I put a gibberish directory in it tells me instantly, but the correct one waits a while then denies me. Can you help? Thanks!

  13. Chris Gray

    Hrm that first line didn’t appear as I pasted it for some reason, the name was “shared” and the hostpath was “/320/Shared”.

  14. Arun

    Chris,

    If you have the new version of Virtualbox, you’ll see some small icons at the bottom of the window (Virtualbox frame) when you run your virtual OS. One is hard drive access, one for USB and there is one for shared folder. Right click that and it’ll open the shared folder window. Click on Add and select the directory in Ubuntu that you want to share. You should be able to find this shared folder option in the virtualbox settings manager too. Once you select the directory you want to share, click OK and close that window. Now go to Windows OS, if you are using that as virtual OS, and enter the command net use M: \\vboxsvr\sharedfolder where sharedfolder is the exact name of the folder you selected in the shared folder window. M is the drive letter, so you can use any drive letter you want (make sure that is not used already). There should be a space between the drive letter and the first backward slash (\).

  15. Chris Gray

    I just tried it that way, and got the same error again. :(

    I changed the drive letters, directories to share, everything, and it still comes up with the same error as above. I’ve also made sure there was a space between the drive letter and \. :)

    Any ideas?

  16. Arun

    Chris,

    It may be a silly question, but did you install Guest Addon?

  17. Chris Gray

    Hrm not so silly, I haven’t installed any addons at all - I figured as it came default with openSUSE 10.3 that it’d have everything I needed. :)

    Would it be “virtualbox-guest-tools-1.5.2-13.3.i586.rpm” or is that something that builds a guest addon? Just confused as to exactly what I need to download.

    Thanks for your help btw.

  18. Arun

    The steps to install Guest addon is there as point no. 2 in this post itself with a screenshot under Sharing mouse control between Ubuntu and Windows without using the control key.

  19. Munich Unix

    nice howto to get sharing set up. a bit easier to follow than the virtualbox sharing instructions.read more| digg story

  20. Chris Gray

    Worked a charm, thanks for your help. :)

  21. Arun

    You are welcome.:)

  22. mariner

    Yes I have installed guest addon - I assume I have done it correctly as the mouse is automatically captured to whatever os I use.

  23. Arun

    I couldn’t check the information for you as I didn’t go home until late at night. I’m sorry. I’ll try to check today, but when I think about it, I got the window bigger by increasing the resolution. I then maximized by clicking the maximize box of the virtualbox window frame. I think there is an option in the Virtualbox menu to make the virtual OS full screen.

  24. Frank

    THanx a million for the tip………
    Now I can smile… :-}
    About to install OS X Leopard!

  25. Arun

    You are welcome :)

  26. Serge Norguard

    hey there, thanks for the tip how ever im getting an error when i try to perform the file sharing. the error that i’m getting is :

    [!] FAILED calling machine->CreateSharedFolder(Bstr(name), Bstr(hostpath), fWritable) at line 6236!
    [!] Primary RC = 0×80070057
    [!] Full error info present: true , basic error info present: true
    [!] Result Code = 0×80070057
    [!] Text = Shared folder path ‘«/home/user/Documents»’ is not absolute
    [!] Component = SharedFolder, Interface: ISharedFolder, {8b0c5f70-9139-4f97-a421-64d5e9c335d5}
    [!] Callee = IMachine, {31f7169f-14da-4c55-8cb6-a3665186e35e}

    any help on this would be great

  27. Arun

    Serge,

    You didn’t say what step is creating that error. Anyhow, If you are using the latest version of Virtualbox, you don’t have to use the Vboxmanage command. You can go to Virtualbox settings and select shared folder option and add the folder you want to share. Boot Windows, login and open the command line. Enter the following command.
    net use driveletter: \\vboxsvr\sharedfolder
    eg: If you want to use P: as the drive letter (make sure your OS is not using P:), then
    net use P: \\vboxsvr\sharedfolder
    As you can see there is a space between : and \\.

  28. Serge Norguard

    oh. thanks, anyway that error occured when i did :

    VBoxManage sharedfolder add virtualmachinename -name «sharedfolder» -hostpath «/home/username/foldertoshare»

  29. Serge Norguard

    just to clarify, when i do the shared folder and then load up virtual box and run the windows command prompt, i type in

    “net use driveletter: \\vboxsvr\sharedfolder”

    and since my “shared folder name” is “Desktop”

    my command line should be

    “net use d: \\vboxsvr\Desktop” ? am I right ?

  30. Arun

    Yes. Make sure d: is not being used by DVD/CD drives or hard drisk etc.

  31. Serge Norguard

    http://pastebin.ca/960967

    Am i doing it right ?

  32. Arun

    Serge, for some reason, my blog does not show the double quotes as double quotes. I have given the command below in wordings. try it.
    VBoxManage sharedfolder add virtualmachinename -name doublquotessharedfolderdoublequotes -hostpath doublequotes/home/username/foldertosharedoublequotes

  33. sayantan

    thanks a lot for the tutorial, i’m new to linux and this virtual box was of utmost importance to me, as i was unable to configure ms office properly in wine

  34. Serge Norguard

    hey Arun. thank you so much . it works now.

  35. Arun

    You are welcome Serge and Sayantan.

  36. vimal

    Hi,
    Thanks to your walkthrough, i was able to have XP as guest inside my Kubuntu Feisty Fawn 7.04. I am migrating from Vista and need to run office., i was able to do that as well.

    Only thing troubling me is to get XP to recognize my wireless card. Any tips??

    Thanks.

  37. Arun

    Vimal,

    I didn’t try wireless connectivity. Did you see if your wireless card was listed under Devices menu or check the settings option. May be it was not enabled in settings.

  38. Vimal

    **update
    got my wireless working as well. pheww!!!
    i had to choose the host interface name which needed to be mapped to the virtual adapter in the settings.

  39. Arun

    Good to know it worked.

  40. Ravi

    Hi Arun,
    I have installed the virtualbox 1.5.6 on ubuntu and installed WinXp sp2 on it but I could never get my mouse working in the virtual box. Can you please guide me?

    Thanks,

    Ravi

  41. Arun

    Ravi,

    First, Sorry for the late response. I don’t normally check my blogs on weekend.
    I’m not sure why it’s not working for you. Did you install it in your laptop or desktop? Couple of people complained about laptop installation. Did you check the settings to see if you have to manually enable the mouse, esp if it’s USB one?

    Also, try disabling Keyboard Auto Capture in the VirtualBox Preferences and see if it works.

  42. Ravi

    Thanks, Arun. I have got it going after I installed the guest applications.

  43. Arun

    Good to know it worked. :)

  44. Reedyseth

    Thanks a lot Arun, I had a little difficulties but I did it, now my Virutalbox Works at 100 %.

  45. Arun

    Good to know that. :)

  46. three

    Im having trouble trying to get my wireless card recognized in virtualbox any ideas Arun?

  47. Arun

    Did you check the settings in Virtualbox. I’m not sure why.

  48. Cuong

    I have used this command

    VBoxManage sharedfolder add Windoze -name linux -hostpath /media/linux

    After adding a shared folder, I failed to start the virtual machine “Windoze” (Windoze is my virtual machine name).

    “Could not create a shared folder “inux” mapped to /media/linux” (VERR_ALREADY_EXISTS)

    Any advices?
    Thanks

  49. Arun

    I’m not sure why. What you can try is to use the shared folder option under settings in the virtualbox software to add the folder you want to share and then use the net use M: \\vboxsvr\sharedfolder command to assign a drive letter to that folder. By doing this, you don’t have to issue the vboxmanage command.

  50. Mark

    just wanna drop a line to say Thanks. - installed G-addon and it works!

Leave a Reply