How to Access Folders on Ubuntu Host Machine from an Ubuntu Virtual Machine in VirtualBox

  1. Right-click your VM, then click Settings
  2. Go to Shared Folders section
  3. Add a new shared folder
  4. On Add Share prompt, select the Folder Path in your host that you want to be accessible inside your VM.
  5. In the Folder Name field, type shared
  6. Uncheck Read-only and Auto-mount, and check Make Permanent
  7. Start your VM
Select The Shared Folder

9. Install dependencies for VirtualBox guest additions:
sudo apt-get update
sudo apt-get install build-essential linux-headers-`uname -r`
sudo apt-get install virtualbox-guest-utils virtualbox-guest-dkms

You’ll see a folder under /media directory named similarly to the folder you selected to share on your host machine with “sf_” added to the beginning of the name.

10. When VirtualBox installed the Ubuntu operating system, it added a group called “vboxsf”. Before you can access any shared folders, you must add yourself to the vboxsf group. To do this, press Ctrl + Alt + T to open a Terminal window. Type the following at the prompt, replacing “[username]” with your username, and press Enter.
sudo adduser [username] vboxsf

11. Run following command in Guest machine:
sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) <Host_machine_shared_dir_name> /media/sf_images/

12. This directory mount we just made is temporary and it will disappear on next reboot. To make this permanent, we’ll set it so that it will mount our directory on system startup
Edit fstab file in /etc directory
vi /etc/fstab
enter followimg line at the end
<Host_machine_shared_dir_name> /media/sf_images/ vboxsf defaults 0 0

13. Restart Guest machine.

14. Enjoy!!!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store