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

Vineet Kumar
2 min readMar 4, 2021


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