VirtualBox shared folder is read-only (SOLVED)
February 18, 2021
VirtualBox Shared Folder allows you to easily exchange files between a virtual machine and a real computer.
By default, the contents of the Shared Folder are owned by the root user. Therefore, the files in the shared folder are read-only for regular users. The following manual shows how to make the VirtualBox shared folder read/write accessible to regular users.
1. Install VirtualBox Guest Additions.
Without Guest Additions, shared folders won't work properly.
2. Add a Shared Folder if you haven't already.
3. Make sure the “Read-only” checkbox is unchecked in the Shared Folder settings.
4. Add your user to the vboxsf group:
sudo usermod -a -G vboxsf $USER
Restart your computer for the changes (the user is added to the group) to take effect.
In theory, this should be enough for the shared folder to become writable. That is, the point is that the folder is mounted so that the group that it belongs to is vboxsf. Users in this group can edit the contents of the folder.
But on some distributions the folder is mounted as owned by the root user and owned by the root group. In this case, regular users have read permissions to the contents of the shared folder, but they cannot edit files in it, create new files, or delete existing ones.
The vboxsf filesystem has uid= and gid= mount options, you can try them with commands like:
sudo mount -t vboxsf -o 'uid=1000,gid=141' SHARE_NAME /PATH/TO/POINT/MOUNT
Or add a line like this to the /etc/fstab file:
SHARE_NAME /PATH/TO/POINT/MOUNT vboxsf gid=141 0 0
But both of these methods did not work in my case.
I tried to change the owner of the folder and its contents using chown:
echo $USER mial sudo chown -R mial /mnt/share
But this did not work either - the owner of this folder was still root.
The only way to make the folder readable was by changing the access rights to it with chmod.
This command will create and modify new files and directories in the shared folder:
sudo chmod 777 /PATH/TO/POINT/MOUNT
Note that changing file permissions changes them not only for the virtual computer, but for the real one too! Therefore, the method described above cannot be considered ideal. If you have any thoughts on how to force the shared folder to be mounted with the vboxsf group, then write in the comments!
- Ubuntu in VirtualBox does not stretch to full screen although Guest Additions are installed (SOLVED) (74.3%)
- VirtualBox Error “NS_ERROR_FAILURE (0x80004005)” (SOLVED) (57.2%)
- Why does VirtualBox lose connection when changing MAC address (SOLVED) (56.4%)
- How to make VirtualBox virtual machines destroy on computer restart (56.4%)
- Analogue of the --force option in pacman (50.8%)
- Swap file and swap partition in Arch Linux (BlackArch): what to choose and how to add Swap (RANDOM - 50%)