Shared folder for Fedora VM in VirtualBox

Hi,

I found a little hard to setup a shared folder for my VMs. So thought of sharing it..

So, assuming you already have your host machine, VirtualBox installed on it and a VM running Fedora (any linux), there we go..

Highlight your VM in VirtualBox window.

Screen Shot 2015-03-17 at 3.40.41 pmYes, it is powered off. Bring up the settings window for the VM clicking the below icon.

Screen Shot 2015-03-17 at 3.41.02 pmChoose the “Shared Folders” tab and you will see the list of folders shared with VM.Screen Shot 2015-03-17 at 3.41.22 pmClick on the plus sign you see on the left side and you get another window like the one below.

Screen Shot 2015-03-17 at 3.41.44 pmYou may choose the folder of the host machine you want to share and tick the “Auto-mount” option. Click OK.

Screen Shot 2015-03-17 at 4.12.42 pm

The folder you chose to share is now visible and we are done with the VirtualBox settings. Click OK to come out of it.

Screen Shot 2015-03-17 at 4.13.05 pm

Now boot up the VM. We need to install a few packages in Fedora for this. You may use below command to install the same.

Screen Shot 2015-03-17 at 5.11.50 pmThis will install latest gcc and kernel-devel packages. Guest addition may get arrogant, at times and gives error that it can’t find a particular version of kernel-devel. I will explain how to solve that later.

Now we can install “Guest Addition”

Click on the “Devices” menu and select the below highlighted option.Screen Shot 2015-03-17 at 4.15.35 pmSome OS automatically run the autorun script from CD. Otherwise open a file-browser and open the CD contents. You will see “autorun.sh” file there. Drag and drop it to Terminal. It will first authenticate you and start installing “Guest Addition”.

Screen Shot 2015-03-17 at 4.59.33 pmScreen Shot 2015-03-17 at 4.53.26 pm

You will get below output 99% of the times and that means just a reboot and you have a host-folder available in VM.

Screen Shot 2015-03-17 at 5.26.14 pm

The shared folder will be auto-mounted in /media.

Screen Shot 2015-03-17 at 5.30.02 pmThe 1% I left earlier is the case when “Guest Addition” fails to install with an error about the kernel-devel version. You may get below screen in such cases.

Screen Shot 2015-03-17 at 4.54.16 pmIn such cases you get a command from the above output.

yum install kernel-devel-3.17.4-301.fc21.x86_64

Just run the below part out of it and do the “Guest Addition” installation again and you are good to go..

yum install kernel-devel-3.17.4

Now let me take you through another issue you may face. Your folder will get listed in /media. But you may not have permission to open it. In my case, “Shared” is the shared-folder. /media/sf_Shared is the path in VM where it is mounted.

ls /media/sf_Shared

The above command will give an output like this:Screen Shot 2015-03-18 at 9.48.20 pm

This is because of the difference of UID in host and VM machines.

Screen Shot 2015-03-18 at 9.24.30 pm

The easiest way to sort this out is to add the user account to vboxsf.

usermod -a -G vboxsf

I went for a reboot (of VM) after that and things worked well.

May be you want to do this too.

Create a link in your home directory to access the shared directory mounted in /media. Make sure your home directory does not have “Shared” folder already.

ln -s /media/sf_Shared ~/Shared

So now you may use ~/Shared as your window to the host-machine..

Published by

Sreejith

A strong believer of: 1. Knowledge is power 2. Progress comes from proper application of knowledge 3. Reverent attains wisdom 4. For one's own salvation, and for the welfare of the world

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s