1

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?

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

1 Answers1

2

In your specific scenario, simply trying to change folder owner won't work. This is what has worked for me:

  1. Create a shared folder SHARED (Host-side), from a local (Guest-side) path /folder/path/, give it full access and uncheck automount option in VirtualBox
  2. Run sudo usermod -aG vboxsf yourusername on the Guest
  3. Take note of your userid; run cat /etc/passwd|grep yourusername from the Guest to find it (it usually is 1000)
  4. 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, replacing gid and uid with previous userid
  5. Reboot the Guest
Gui Imamura
  • 335
  • 2
  • 3
  • 18
abkrim
  • 332