Fix shared folder not working in VirtualBox

Learn why a VirtualBox shared folder fails and how to fix permission denied errors. Step-by-step guide for Linux guest systems with Guest Additions.

7 min read1 viewsFix shared folder not working in VirtualBox
— · 0 votes
Contents
  1. Check Guest Additions Installation
  2. Add Your User to the vboxsf Group
  3. Configure the Shared Folder in VirtualBox
  4. Mount the Shared Folder Manually
  5. Fix Permission Denied on Linux Guest
  6. Troubleshoot Guest Additions Mount Errors
  7. Check Host Folder Permissions
  8. Verify Shared Folder Access in the Guest
  9. VirtualBox Shared Folder Questions
  10. Why does my VirtualBox shared folder show permission denied?
  11. How do I add a user to the vboxsf group?
  12. Do I need Guest Additions for VirtualBox shared folders?
  13. How do I mount a VirtualBox shared folder manually?
  14. How do I make VirtualBox shared folder permanent?
  15. Can I use a shared folder without automount?

A shared folder not working in VirtualBox is often a permission issue or missing Guest Additions. The host folder is configured in the virtual machine settings but the guest system cannot access it. You can fix this by installing Guest Additions, adding your user to the vboxsf group, and mounting the folder correctly.

  • Install Guest Additions inside the guest for shared folder support.
  • Add your Linux user to the vboxsf group to avoid permission denied errors.
  • Mount the shared folder manually or with automount and check the mount point permissions.
  • Restart the virtual machine after changing group membership or installing Guest Additions.
  • Host folder permissions and firewall settings can also block access.

Check Guest Additions Installation

Guest Additions provides the drivers needed for shared folders. Without this software the guest system cannot see the shared folder at all. In the virtual machine window choose Devices then Insert Guest Additions CD image. Then run the installer inside the guest operating system.

A Linux guest needs build tools and kernel headers before installing Guest Additions. The installer script shows an error if these packages are missing. Install them with the package manager of your distribution. After installation reboot the virtual machine.

You can verify Guest Additions is working by checking the kernel module. Open a terminal in the guest and run lsmod | grep vboxguest. A line with vboxguest means the driver is loaded. If you see nothing the installation did not complete correctly.

Add Your User to the vboxsf Group

Permission denied on a shared folder usually means your user is not in the vboxsf group. VirtualBox creates this group to control access to shared folders. Only members of the group can use them. Adding your user takes one command and a reboot.

Run sudo usermod -aG vboxsf your_username in the guest terminal. Replace your_username with the actual account name. The change applies only after you log out and back in or reboot. Then the system knows your user belongs to the group.

Check group membership with the groups command. Your username should appear next to vboxsf in the output. If it is missing repeat the usermod command. A login shell refresh is sometimes needed before the new group appears.

Configure the Shared Folder in VirtualBox

The host folder must be set up correctly in the virtual machine settings. Open the settings of the powered-off machine and go to Shared Folders. Add a new shared folder with the folder path on the host and a name for the guest. Choose a mount point or enable automount.

A permanent shared folder is different from a transient one. A permanent folder remains in the configuration after the machine shuts down. A transient folder disappears unless saved as a machine state. Pick the permanent option for regular use.

The folder name you set here is the one the guest sees. Write it down without spaces to avoid mount confusion. In a Linux guest the automount usually places it under /media/sf_name. The mount point is created for you but permissions still apply.

Mount the Shared Folder Manually

Sometimes automount fails and you must mount the folder by hand. First create a mount point with sudo mkdir /mnt/shared. Then run sudo mount -t vboxsf share_name /mnt/shared. Replace share_name with the folder name from the VirtualBox settings.

This mount lasts until the guest shuts down. Add a line to /etc/fstab for a permanent mount. The fstab line looks like share_name /mnt/shared vboxsf defaults 0 0. Test the mount before relying on it.

Read and write access depends on the mount options. With defaults a member of vboxsf can read and write. A read-only mount is enforced with the ro option. Use mount -o ro for a folder that should not change.

Fix Permission Denied on Linux Guest

A permission denied error after mounting means the folder is not accessible to your user. The root cause is often the host folder permissions or the vboxsf group. Check the shared folder with ls -l on the mount point. The group should be vboxsf with read and write for group members.

If the group is wrong the mount options may be incorrect. Remount with explicit options like sudo mount -t vboxsf -o uid=1000,gid=1000 share_name /mnt/shared. Use your user id and group id from the id command. This sets the owner on the mounted folder.

On Ubuntu the error can happen even with correct settings. The apparmor profile for VirtualBox may block access. Adjust the profile only if you understand the security implications. A simpler workaround is to copy files with sudo.

Troubleshoot Guest Additions Mount Errors

Mount errors like protocol error or invalid argument point to Guest Additions problems. The guest additions version must match the VirtualBox version on the host. Update Guest Additions after a VirtualBox upgrade. Reinstalling clears many mount issues.

Sometimes the kernel modules are built for a different kernel. After a guest system kernel update you must rebuild Guest Additions. Run the installer again and watch for compilation errors. A reboot loads the new modules.

The vboxsf module is required for shared folders. Load it with sudo modprobe vboxsf. If modprobe fails the module is not built. Reinstall Guest Additions with kernel headers installed.

Check Host Folder Permissions

The host folder itself may block access even when everything else is right. On the host check the folder sharing settings and permissions. The user running VirtualBox must have read access to that folder. On Windows the folder must not have inheritable permissions that deny the VirtualBox process.

Network shares on the host can be problematic. A folder on a remote server may not work as a VirtualBox shared folder. Move the data to a local drive for testing. Local folders eliminate network authentication issues.

Encrypted folders or special file systems on the host may not expose files properly. A folder on an encrypted volume works only after the volume is unlocked. Ensure the host can read the files before the guest tries to access them.

Verify Shared Folder Access in the Guest

After mounting test the access with a simple file operation. Open a terminal and change to the shared folder directory. Create a test file with touch test.txt. If the command succeeds you have write access.

Read the file list with ls to see host files. A successful listing means read access works. Editing a host file from the guest may be blocked by file locks. Close the file on the host first.

For desktop environments the file manager shows the shared folder under its mount point. Some file managers need a refresh to display new mounts. Pressing F5 or reopening the window updates the view.

VirtualBox Shared Folder Questions

Why does my VirtualBox shared folder show permission denied?

Permission denied happens when your guest user is not in the vboxsf group. Add the user with sudo usermod -aG vboxsf your_username and reboot. Also check the host folder permissions and the mount options.

How do I add a user to the vboxsf group?

Open a terminal in the guest and run sudo usermod -aG vboxsf your_username. Replace your_username with the actual account name. Log out and back in or reboot for the change to take effect.

Do I need Guest Additions for VirtualBox shared folders?

Yes, Guest Additions provides the vboxsf driver that allows shared folders to work. Without it the guest cannot access the host folder. Install Guest Additions from the VirtualBox menu.

How do I mount a VirtualBox shared folder manually?

Create a mount point like /mnt/shared with sudo mkdir -p /mnt/shared. Then run sudo mount -t vboxsf share_name /mnt/shared. Replace share_name with the folder name from VirtualBox settings.

How do I make VirtualBox shared folder permanent?

Edit /etc/fstab and add a line like share_name /mnt/shared vboxsf defaults 0 0. Save the file and test with sudo mount -a. The folder mounts automatically at boot.

Can I use a shared folder without automount?

Yes, you can mount the shared folder manually or with a custom fstab entry. Automount is convenient but may not set the permissions you need. Manual mounting gives you control over mount options.

Read next

Latest articles