VirtualBox: access Windows-host shared folders from Ubuntu-guest

April 9th, 2008
This is the scenario that you run Windows as your host operating system and Ubuntu in a VirtualBox, and that you want to access a specific Windows folder from Ubuntu.

First you have to make sure that have install Guest Additions. From the VirtualBox's menu go to Devices → Install Guest Additions... This will mount a virtual CD on your /media/cdrom. Normally this folder's window will show up. As root run the program VBoxLinuxAdditions.run. When the program completes reboot your VirtualBox.

With Guest Additions installed you may now go ahead and define the shared folder(s). From the VirtualBox's menu go to Devices → Shared Folders. A dialog will show up. In this dialog you can specify which folder from your Windows system you want to share with your Ubuntu. Press the button with the + symbol to add a new shared folder in the list. You will have to specify a Folder Name for each folder you add. Make sure you memorize that name because you will need it very soon.

When done with you shared folder(s) specification, you may now go ahead and actually mount these folders from Ubuntu. First you have to create a mounpoint, that is, a directory in your Ubuntu which will reflect the shared folder from Windows:

# sudo mkdir /media/windows-share

Of course you may choose an alternative path for your mountpoint. With your mountpoint created you can now mount the shared folder, like this:

# sudo mount -t vboxsf folder-name /media/windows-share

Where folder-name will be the name you assigned for this folder when you were adding it in the shared folders list.

You could use the /etc/init.d/rc.local script to execute these commands on startup to have the shared folders automatically mounted every time you start your Ubuntu VirtualBox.

53 Responses to “VirtualBox: access Windows-host shared folders from Ubuntu-guest”

  1. Pablo Says:
    Very useful!!!
    thanks a lot for this article...

    From Chile - Southamerica

    pamorale
  2. Pindey Says:
    thank you so much!!!
  3. Pindey Says:
    One question though, how do I used the " /etc/init.d/rc.local" ?
  4. vastan Says:
    but in my machine, i get this message

    mount: unknown filesystem type 'vboxsf'
  5. D'Amico Says:
    This is just what I needed! I would add that the shared folder may need to be in the following directory: C:\Program Files\Sun\xVM VirtualBox
  6. SeanG Says:
    Works like a CHARM. THANKS for outlining this.
  7. Kaiyuan Says:
    Sorry, I'm pretty new to OS stuff, so my question might be quite low level.

    Qn) There are several VBoxLinuxAdditions(sth).run. How do I know which one I should choose?
  8. Eric Says:
    Great tip, thanks for sharing this! FYI this is what I added to my Ubuntu VirtualBox guest /etc/rc.local file (top section of rc.local omitted). It now connects to the shared folder automatically on startup, as the blog owner stated. Very cool! (I have _VirtualBoxShared added under Vbox menu Devices > Shared Folders. _VirtualBoxShared is the name of the actual folder on my Windows Vista host box.) The folder ubushare is what I created instead of the tutorials /media/windows-share example.

    #
    # By default this script does nothing.

    mount -t vboxsf _VirtualBoxShared /home/ubuntu/ubushare

    exit 0
  9. Ran Says:
    Finally, a quick solution that works! Thank you!
  10. fisher Says:
    I've followed the guide and I still can't get this to work.

    After I set up the folders I keep getting this :

    fisher@fisher-laptop:~$ sudo mount -t vboxsf VBShare /home/fisher
    [sudo] password for fisher:
    /sbin/mount.vboxsf: mounting failed with the error: Protocol error

    Can anyone help me out with this?
  11. dolphin Says:
    thanks for sharing this, couldn't be easier !
  12. codeamatic Says:
    thanks for sharing, this definitely was a quick solution to my problem... much appreciated...!!!
  13. An Aspiring Person Says:
    I have a question... Is it possible to unmount the shared folder??? I accidentally put it in the wrong directory...I'm an ubuntu noob...
  14. mj Says:
    thanks ,a lot ....it really workssssssss
  15. Badri Says:
    Thanks a lot!! Very helpful article.
  16. Badri Says:
    Thanks a lot!!
  17. saycat Says:
    A great solution, thanks!
  18. stuntpilot Says:
    Great site! You really helped me with the shared folders in virtualbox.

    Good luck being smoke free!

    You made the right decision.
  19. ubuntuuser Says:
    mount is not working for me!

    but I use this command instead:

    mount.vboxsf NAME /PATH/TO/FOLDER
  20. Paul Reinheimer Says:
    Thanks for documenting this. I'm used to a few other VM tools where this is all automagic, I couldn't figgure out why it wasn't working.
  21. zourtney Says:
    Anyone having problems might be helped be this link:
    http://forums.virtualbox.org/viewtopic.php?f=8&t=17827#p77284

    I was initially getting something along the lines of "filesystem vboxsf unknown" but resolved it by following the steps in that post.

    Note: do not run "guest additions" shell script from the window manager -- use the command line. I tried running the script by double clicking on it and it did not work (permission problem, probably).

    Works now!
  22. Alex Says:
    >>I have a question... Is it possible to unmount the shared folder??? >>I accidentally put it in the wrong directory...I'm an ubuntu noob...

    I had the same problem =)
    To unmount folder use this:
    sudo umount /media/windows-share
    where /media/windows-share - your wrong directiory
  23. Kemi Says:
    I've spent about 20 hours trying to find help on this... and found your article, which solved my issue in 2 minutes! Thanks!
  24. lunix rookie Says:
    as clear as crystal.
    Thanks
  25. Christine Says:
    This was very useful, thanks!
  26. Jimbo Says:
    @fisher
    - Check to make sure that "vboxsf" is the name of your shared folder in "Devices > Shared Folders". That was causing the same error for me.
  27. Colin Phelps Says:
    This is a great article. The only suggestion as a Linux newbie is that a detailed explanation of the sybtax would be great to get a complete understanding.
  28. Anton Says:
    Glad I found this article. You saved me many hours of going throuhg the docs. Thanks !
  29. SRib Says:
    Help a newbie

    How do i avoid to insert sudo mount -t vboxsf folder-name /media/windows-share
    every time a start ubuntu?
    And how to make it available at "PLACES"

    tks in advance
  30. SRib Says:
    forgot to add

    great post :)
  31. FID Says:
    Hi,

    Thanks a lot! Worked great!
  32. Tim Says:
    I had to:

    sudo apt-get install dkms

    then reinstall the guest additions, reboot and then:

    sudo mount -t vboxsf folder-name /media/windows-share

    and it worked.
  33. Debasis Goswami Says:
    Wonderful! It worked exactly as the article published. Helps me playing with my Linux toy :)
  34. Ankush Says:
    thanks a lot. . .It's really an easy solution to the specified problem! ! ! nd ur solution works like a charm! ! ! ! ! !
  35. mo Says:
    so far that sums up my linux experience. why do i have to do something as fundamental as mounting a drive using the command line?? i don't want to go back to the DOS days, it's 2009 not 1989. could you please describe how to do this using a gui?!!
  36. Duncan Says:
    Nice one. I *needed* this info :)
  37. donnie Says:
    To have the shared folder show up when you boot Ubuntu, add a line like this in /etc/fstab:

    folder-name /media/windows-share vboxsf uid=myusername 0 2

    Don't use a startup script to mount a filesystem.
  38. Glen Says:
    fisher, I had this problem too

    You need to run the command from another dir (e.g. do not run it from the /media dir)

    Anyways, great tutorial - Thanks!
  39. Pankaj Kumar Says:
    Thanks... it worked... :)
  40. Chris Says:
    Just as an alternative - you can configure your guest network adapter as bridged. This will allow the guest to get an address on the same subnet as your host from the DHCP server. From there, you can use WinSCP to copy files back from a linux installation that has SSH set up on it.
  41. Kerem Says:
    Perfect Thank you it works
  42. john mower Says:
    had to use mount.vboxsf, mount -t vboxsf wouldn't work for me. thanks!
  43. Dan Says:
    Hi, I did the above and it works, but I can't write to it from Ubunto, it say's Permission denied. I tried to sudo chmod, sudo chown. In the virtual box I did set it to mount permanently, but did not check off readonly. In windows I did the same. I can write as root, but just not as the regular user
  44. TuanAnh Says:
    Awesome, thank you so much!
  45. MCdatashed Says:
    Thanks loads for this! Very easy to follow and helpful.
  46. Mr T Says:
    Worked like a charm! Thanks!
  47. Teiji Says:
    Thanks. Now I can share files. Also, thanks donnie for the tips.

    Now, to figure how to make the windows-share as a desktop shortcut....
  48. Teiji Says:
    "Now, to figure how to make the windows-share as a desktop shortcut.... "

    Nvm, ctrl+ shift drag did the trick. :)
  49. neftalí Says:
    Good tip. Thank you.
  50. Valmond Says:
    Excellent, a Big Thanks!!!!
  51. Georg Says:
    Great!
    Also works well for USB-Sticks. (I never found a way to reliably accesss them under VirtualBox.) Thanks!
  52. scott Says:
    thanks for the pointer. i did this and it worked flawlessly.

    so i got the brilliant idea to share a fat32 usb disc rather than repartition my ntfs drive (permissions issues with ntfs not fun). so i shared my empty usb disc and mounted it, but i couldn't ls on the disc. said:

    "/bin/ls: cannot open directory .: Operation not permitted."

    what the? it worked 2 minutes ago!

    it seems the disc IS working, but for some reason ls fails on an empty disc. so i created a text file:
    vi hi.txt

    i edited and saved the file. worked fine. i was then able to ls on the top-level directory.
  53. Pranav Says:
    Thanks ... It really helped me to mount a windows shared box on Ubuntu

Leave a Reply