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.
Yes, it is powered off. Bring up the settings window for the VM clicking the below icon.
Choose the “Shared Folders” tab and you will see the list of folders shared with VM.Click on the plus sign you see on the left side and you get another window like the one below.
You may choose the folder of the host machine you want to share and tick the “Auto-mount” option. Click OK.
The folder you chose to share is now visible and we are done with the VirtualBox settings. Click OK to come out of it.
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.
This 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.Some 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”.
You will get below output 99% of the times and that means just a reboot and you have a host-folder available in VM.
The shared folder will be auto-mounted in /media.
The 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.
In 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.
The above command will give an output like this:
This is because of the difference of UID in host and VM machines.
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..