Sharing folders between host and guest OS in VirtualBox

[Host OS: Windows XP, Guest OS: Ubuntu 8.10]

If you are using VMware as your virtualisation software you will be able to copy files directly from the host to the guest OS, and vice versa. But unfortunately this feature does not exist in VirtualBox. Not yet at least.

However, there is a very easy way you can share files between the host and guest when using VirtualBox – using Shared Folders.

First you have to create folder in your Windows host. For example, create a folder on your desktop called “myshared“.

Then start your Ubuntu VM. After you get to the desktop, press the right-Ctrl button so that your mouse pointer can move outside the Ubuntu desktop. From the menubar, go to Devices-> Shared Folders. After that click the Add New Shared Folder button and then browse to the folder you created earlier (myshared). Make sure you tick the “Make Permanent” checkbox.

selecting folder to be shared

After you have added the folder, click OK and return back to your Ubuntu desktop. Then create a folder in Ubuntu which will be used as the shared folder on the guest OS. For example, create a folder called “SharedItems” on your desktop.

Then open a new Terinal window (Applications -> Accessories -> Terminal) and execute the following command:

sudo mount -t vboxsf myshared Desktop/SharedItems

The text in red is the name of the shared folder in the Windows host and the text in blue is the directory path of the shared folder on the Ubuntu guest.

Once you’ve done that, you can now share files between the two OSs by simply placing files in the folders. Here’s an example. I put a GIF file in the myshared folder and when I open the SharedItems folder, I have that file available for me.

tadaa!

There’s just one more thing to do now. To make sure that the shared folders are mounted automatically when you start your computer, open Terminal and execute the following command:

sudo gedit /etc/init.d/rc.local

This will open the rc.local file in Gedit. Now scroll to the bottom of the file, add the following line and save it.

sudo mount -t vboxsf myshared /home/nass/Desktop/SharedItems

Once again, the red text is the name of the shared folder in the Windows host and the text in blue is the directory path of the shared folder on the Ubuntu guest.

The difference here is that since I created my folder on the Desktop, I had to give the full path. But earlier I didn’t have to write the “/home/nass” part because when you open Terminal, by default you are placed in your Home folder.

10 Responses to “Sharing folders between host and guest OS in VirtualBox”

  1. alex Says:

    thanks alot, worked like a charm

  2. sowmithry Says:

    Thanks a lot,
    If I want to share folders between Host Ubutnu and Guest Windows XP/ Vista.
    And if I want to share folders which are not on desktop, like if I want to share folder “oracle” which is under /opt/oracle in my Ubuntu 8.10 with my Guest OS windowsXPSP2/Vista.
    Thanks waiting for ur mail my ID: sowmithry87@gmail.com

  3. esender Says:

    Sweet thanks.

    One thing I noticed on Ubuntu 8.10 is that the shared folder should have all lower cases. I noticed that it gave me a “Protocol error” right before I tried lower case.

    Not sure if that is common Linux knowledge, I am pretty new to it all..

  4. ClarkKent Says:

    Extraordinarity: ,

  5. analiseramil Says:

    thanks so much!

  6. Ajeet Says:

    Thanks a lot buddy. Very helpful stuff.

  7. Kiran Kumar Says:

    Thanks a lot..

  8. jeri Says:

    thanks a bunch! :)

  9. Bob10 Says:

    Why aren’t you answering any of these questions? ,

  10. Coder44 Says:

    In the most extreme cases nucleotides are inserted and deleted. ,

Leave a Reply