VirtualBox is a great application for trying out different Linux distros without messing with your current build. In this post I'll show you how to share a folder between your Linux host and the guest virtual machine. This assumes you have already installed VirtualBox, created and installed your guest OS, and installed VirtualBox Guest Additions.
On you host machine, create a folder to share. I'll call mine vbox.
Start up your guest OS in VirtualBox. In the window for the running virtual machine, select Devices->Shared Folders... Click the icon to Add a New Shared Folder. Select the Folder Path drop-down and click Other. Navigate to your shared folder and click Choose.
Click OK twice. That was the easy part.
Go into your guest OS and open a terminal window.
Create a new directory where you'll mount the shared folder.
Enter the id command and look at the output. You should see something like:
uid=1000(user) gid=1000(user) groups=4(adm),20(dialout),24(cdrom),46(plugdev),106(lpadmin),121(admin),122(sambashare),1000(user)
It's the uid and gid parts that are important. Now you will mount the shared folder from the host to the guest OS. From a terminal in the guest OS:
Make sure to make the proper substitutions for uid and gid as well as the host and guest folder names (vbox and /home/user/share respectively).
You should now be able to share files between your guest and host.
Make the Mounted Share Permanent
You can make the shared folder mount automatically each time you start the virtual machine by making an entry in /etc/fstab. From the guest:
Add a line at the bottom that looks like this:
vbox /home/user/share vboxsf rw,uid=1000,gid=1000 0 0
Again, make the appropriate changes for your folder names and user/group ids.
#
One question, everytime I restart my VM my shared folder is still here (without editing the fstab file so no linked) but I cannot remove it. If I go to devices -> shared folder -> remove share folder:
Failed to remove the shared folder "blabla" (pointing to path_on_host) from the virtual machine VMname
Please close all the programs in the guest OS that may be using this shared folder and try again
Could not remove the shared folder 'blabla' (VERR_PERMISSION_DENIED)
I hesitate a bit to just rm ~/share
Some advice ?
Thanks
#
Thanks for posting this. It is nearly working for me. I can't get the fstab entry to work (yes,I triple-checked the syntax). I even tried putting the mount command that works from my user command line in rc.local. It didn't work there either. Go figure.
BTW, your website has bee intermittently offline for the past 30 mins, and no cache was available at cloudflare. Just in case you wanted to know. It took 3 attempts to post this reply.
#
in terminal: sudo mount -t vboxsf *sharedfolder* *mountpoint* --> where *sharedfolder* is the name of the folder in VirtualBox settings (host OS) under "shared folders" and *mountpoint* is where you want to have files from host os on you guest os linux e.g. /home/sam/myfiles
#
Not who you are replying to, but thanks a lot!
That protocol error was driving me insane!
#
I was trying a lot and I was unable to get my share files....
looking on directories i think they could be... i found it in root /media/ folder, so just add the folder in vbox, open the linux guest and look for the media folder.
#
I am getting an error /sbin/mount.vboxsf: mounting failed with the error: Protocol error
#
Are you running Ubuntu Lucid Beta as your guest OS? I had this problem with the Alpha3 release of Lucid. I think it has to do with Ubuntu removing HAL and replacing it with DeviceKit for hardware interaction.
Make sure you're using the latest version of VirtualBox and the latest version of VirtualBox Guest Additions. Though I'm not sure if VirtualBox has fixed the issue yet.
#
I'm running the latest updates in Lucid and the shared folders are now working.
#
Thank you!
#
nothing easier as what you described, but what is with:
share-folders linux-host & windows-virtual-machine virtualbox
???
#