Why can't I access a shared folder from within my Virtualbox machine?
You have to mount your folder on your VM.
First you need to install Guest Additions (although I already did this during the installation).
- Start your VM
Devices
>Insert Guest Additions CD image...
- I had to manually mount the CD:
sudo mount /dev/cdrom /media/cdrom
- Install the necessary packages:
sudo apt-get install make gcc linux-headers-$(uname -r)
- Install the Guest Additions:
sudo /media/cdrom/VBoxLinuxAdditions.run
Now you can mount your share using:
mkdir ~/new
sudo mount -t vboxsf New ~/new
Where New
is the name of your shared folder.
Now you can access the shared folder at ~/new
.
Note: this is not permanent. To permanently mount your folder you should add the following line to /etc/fstab
(sudo nano /etc/fstab
):
New /home/user/new vboxsf defaults 0 0
Obviously you should replace user
in /home/user/new
by your own username.
How to access Windows Host shared directory from Ubuntu VirtualBox Guest:
- Create a directory in Windows on any location of your choice.
- In the VirtualBox go to the settings of the Ubuntu Guest.
- Under the Shared Folder section add the location of you folder created with full permission.
- Now start the ubuntu guest, and make sure that you have the latest VirtualBox Guest Additions installed
Now add your user to the vboxsf group:
sudo usermod -aG vboxsf $(whoami)
Logout the user and login again.
- Now you can access your shared directory in
/media/sf_(shared_folder_name)
.
How to share folders in virtual box (Step by Step Guide)
- Go to
Virtual Box/Device/Shared
Folder (on host OS) - Add a folder that you want to share in the pop-up. (on host OS)
- Let’s name this folder “Shared” (on host OS)
- Now Go to Device and install guest addition.
Now next step would be to create a folder that you want to sync with host OS, but make sure that you are at
/home/UserName
.You can check it by typing pwd in the terminal. Now creating directory -
mkdir Share sudo chmod 777 /home/userName/Share
Now install guest additional package (Crucial step! People generally miss this which creates an error “Unknown file type “vboxsf”)
sudo apt-get install virtualbox-ose-guest-utils
Now do the final step by mounting the folder (on guest OS)
sudo mount -t vboxsf share ~/Share/
Done! now sync files between Host and Guest OS through virtual box.