How to share files between Host and Guest in Virtual Box

With the “shared folders” feature of Virtual Box, you can access files of your host system from within the guest system. This is similar how you would use network shares in Windows networks — except that shared folders do not need require networking, only the Guest Additions. Shared Folders are supported with Windows (2000 or newer), Linux and Solaris guests.

Shared folders must physically reside on the host and are then shared with the guest, which uses a special file system driver in the Guest Addition to talk to the host.

To share a host folder with a virtual machine in Virtual Box, you must specify the path of that folder and choose for it a “share name” that the guest can use to access it. Hence, first create the shared folder on the host; then, within the guest, connect to it.

Required: Virtual Box Guest Additions 

Guest Additions provide additional capability to a guest virtual machine, including file sharing. But there are some other consequences you may face;

If your Guest is Windows

If your Virtual Machine running a window version then that will be a easy task to do it. Let see how…

Step 1. Go to your Virtual Box home screen, Click on Devices> Install Guest Additions..

virtualbox-install-guest-additions

Step 2. New window will pop-up like this click Next and reboot your Virtual Machine. That’s it.

virtualbox-guest-addons-setup

If your Guest is Linux

There may be other consequences you may face, we will discussed it step by step.

Follow the above steps, go to home screen click on Device> Install Guest Additions. It will mount a drive on your Virtual Machine CD-ROM.

If Guest Additions showing on CD-ROM then run the following script in terminal.

If you are running a Linux guest, open a terminal and type:
cd /cdrom or cd /media/<cd name>

then run:
sudo sh ./VBoxLinuxAdditions.run

If Guest Additions not showing on CD-ROM then you have to download Guest Addition Manually. There are two choices:

Choice 1. Download Guest Addition from Virtual Box official Website down below is the link to download. Mount the image to CD-ROM of your Virtual Machine. It will showing like in image.

https://www.virtualbox.org/wiki/Downloads // Download extension pack.

virtualbox-addons-isoChoice 2, Open the terminal of Guest running on Virtual Machine, type the following..

sudo apt-get install virtualbox-guest-additions-iso

Whether you finish with choice 1 or choice 2 after that Guest Additions will shown on CD-ROM of Virtual Machine. Run the script as above as you see Guest Addition in CD-ROM.

cd /cdrom or cd /media/<cd name>

then run:
sudo sh ./VBoxLinuxAdditions.run

Create Shared Folder

After you had a Guest Addition, now you need to create shared folder in both Guest and Host.

Step 1. Create a folder anywhere in your Host system where you want and named it what you want. I’ve created one called VboxShare in my home directory.

Step 2. Go to your Virtual Machine home screen and click Guest setting then shared Folder. Then move your mouse to “+” icon to add a shared folder. Like this image…

37ax3

Step 3. New window will pop-up like this. Choose the Folder Path you created on your home directory on your Host system. Type a name for shared folder in Folder Name box. I named it VboxShare.

Select the Auto-mount option. Then click OK.

mnI8T

Step 4. Job Done the shared folder appears on you guest machine as /media/sf_Vboxshare.

iV3YHStep 5. There is only one more step add any user in your guest system that needs access to the folder to the group vboxsf: Open the terminal and type..

            sudo adduser $USER vboxsf

Log out and back in, everything should work fine now.