I am using a VM with Ubuntu 18.04 with GUI, and I am working on a Wordpress project with Nginx. I installed VBox guest additions, but I cannot change the owner of the shared folder, which I have set to auto mount in the /opt folder; the path to the shared folder is /opt/myfolder/THISFOLDER. I want to edit contents (files) inside THISFOLDER. I have tried the command sudo chmod -aG vboxsf myusername
and rebooted to no avail. When I do sudo chown -R myusername /opt/myfolder
, it also doesn't do anything. How can I fix this?
Asked
Active
Viewed 4,367 times
1

Organic Marble
- 23,641
- 15
- 70
- 122

AviG
- 133
-
Does this link help? https://www.howtogeek.com/438435/how-to-use-the-chown-command-on-linux/ – graham Sep 16 '19 at 15:14
-
@Graham no it does not. I have tried what's in the OP. – AviG Sep 16 '19 at 15:24
-
VBox host folder mounts don't exactly 'share' chmod permissions properly with the host, as the VM will consider it 'remote fileshare storage'. You would have to alter the mount options for how you mounted the folder in the system to match the user you want ot to match at mount option time, as yuo cna't chown/chmod a VBox Shared Folder in a way that works right (Same behavior applies to VMware shared folders too) – Thomas Ward Sep 16 '19 at 15:54
-
@ThomasWard how would I alter the mount options? I've already used the VBox shared folder settings to mount with Full access and Auto Mount. I installed via the built in option in "Devices." I'm on a Mac – AviG Sep 16 '19 at 16:02
-
How is it mounted inside the guest? What command did you run to mount it inside the guest OS? If you used the vbox automatic mounting it will use its user that is running the tools - root and superuser - which is why you get permissions issues – Thomas Ward Sep 16 '19 at 16:04
-
@ThomasWard I used this method: https://www.tecmint.com/install-virtualbox-guest-additions-in-ubuntu/. Do I need to uninstall it and redo it? – AviG Sep 16 '19 at 16:10
-
No, it's not an issue with the installed guest additions. Using the 'automount' function is going to mount it differently than you need. I'll have to dig deeper when I get a chance to see if we can 'reset' this to use a different mount user. – Thomas Ward Sep 16 '19 at 16:20
-
Let us continue this discussion in chat. – AviG Sep 16 '19 at 16:26
1 Answers
2
In your specific scenario, simply trying to change folder owner won't work. This is what has worked for me:
- Create a shared folder
SHARED
(Host-side), from a local (Guest-side) path/folder/path/
, give it full access and uncheckautomount
option in VirtualBox - Run
sudo usermod -aG vboxsf yourusername
on the Guest - Take note of your userid; run
cat /etc/passwd|grep yourusername
from the Guest to find it (it usually is 1000) - Edit
/etc/fstab
to add mount point to it:SHARED /folder/path/ vboxsf defaults,dmode=755,fmode=644,gid=1000,uid=1000 0 0
on the Guest, replacinggid
anduid
with previous userid - Reboot the Guest

Gui Imamura
- 335
- 2
- 3
- 18

abkrim
- 332
-
-
-
1
-
-
-
Quick note,
dmode=755,fmode=644
is not needed for everyone and changes files/directories permissions in the guest. – antou Mar 28 '22 at 16:21 -
This is a functional workaround because clicking
Make Permanent
in the VirtualBox settings for the share doesn't actually work. – Gui Imamura Jan 03 '24 at 19:01 -
Also, a comment on this answer states that
sudo adduser your_username vboxsf
(instead of item 2) is better because it is clearer and has better output – Gui Imamura Jan 03 '24 at 19:09 -
1I have answered a question about this question: Editing "/etc/fstab" to add a mount point: I need clearer instruction. – user68186 Jan 03 '24 at 19:25