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.
$ sudo mkdir /mnt/shared_folder
$ 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.
$ 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.
$ sudo nano /etc/fstab
SharedFolderName /mnt/shared_folder vboxsf defaults 0 0
$ sudo reboot
$ 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 |