In VirtualBox, shared folders provide an easy way to share files between the host and guest operating systems. However, after adding a shared folder in the VirtualBox settings, it must be mounted inside the guest OS for access. If you're using an Ubuntu-based virtual machine, you can manually mount the shared folder or configure it to mount automatically on boot.

To mount shared folders in Ubuntu, the Guest Additions package must be installed. This package includes drivers and utilities that enable integration features like shared folders, clipboard sharing, and improved display support. Without Guest Additions, shared folders will not function properly.

Once the shared folder is mounted, the guest system can access the files in the specified directory. You can either mount the shared folder manually, which requires running commands each time the VM starts, or configure automatic mounting through /etc/fstab for convenience. This guide will cover both methods to ensure smooth file access.

Ensure that Guest Additions is installed on the Ubuntu VM, and that a shared folder has been configured in VirtualBox settings.

Steps to mount shared folders in Ubuntu VirtualBox VM:

  1. Start the virtual machine and log in to the Ubuntu guest OS.
  2. Open the terminal in Ubuntu.
  3. Create a directory where the shared folder will be mounted.
    $ sudo mkdir /mnt/shared_folder
  4. Mount the shared folder using the vboxsf filesystem.
    $ sudo mount -t vboxsf SharedFolderName /mnt/shared_folder

    Replace SharedFolderName with the name assigned to the shared folder in VirtualBox settings. Files will be accessible at /mnt/shared_folder.

  5. Verify the folder is mounted by listing its contents.
    $ ls /mnt/shared_folder
    file1.txt  file2.txt  directory1

    If “Permission denied” occurs, add the user to the vboxsf group.

    $ sudo usermod -aG vboxsf $USER

    Log out and log back in to apply the changes.

  6. Open /etc/fstab for editing.
    $ sudo nano /etc/fstab
  7. Add the following line to mount the shared folder automatically on boot.
    SharedFolderName  /mnt/shared_folder  vboxsf  defaults  0  0
  8. Save the file and reboot the virtual machine.
    $ sudo reboot
  9. After reboot, verify the folder is mounted.
    $ ls /mnt/shared_folder
    file1.txt  file2.txt  directory1

    If the shared folder is not mounted after reboot, manually load the vboxsf module.

    $ sudo modprobe vboxsf

This guide is tested on Ubuntu:

Version Code Name
22.04 LTS Jammy Jellyfish
23.10 Mantic Minotaur
24.04 LTS Noble Numbat
Discuss the article:

Comment anonymously. Login not required.