29

My Setup is as follows -

Host: Ubuntu Server 14.04 Guest: Lubuntu Desktop 15.10

I have shared dirs on host to guest with automount option, and the directories show up in Guest OS's just fine - /media/sf_sharename

Also, the user of guest is added to vboxsf group.

The problem is that all the shared dir and its contents are owned by root. I have tried chown -R, but it finishes without reporting error wihtin guest but the ownership does not change.

I have another setup where guest is ubuntu desktop 15.10, and I did not face this problem there.

I need rw access on those shared dirs. How to fix this?

NRJ
  • 385
  • 1
  • 4
  • 11

4 Answers4

29

On Ubuntu Server host execute these commands :

sudo chmod -R 777 /path-to-shared-folder/shared-folder

sudo chown -R user1:user1 /path-to-shared-folder/shared-folder

On Lubuntu Desktop guest execute this command :

sudo usermod -G vboxsf -a user2

Restart the guest system for changes taking effect.

Note : user1 = your host user name | user2 = your guest user name

Frank N
  • 1,340
cl-netbox
  • 31,163
  • 7
  • 94
  • 131
  • 1
    To add a user to an existing group, you can also simply use sudo adduser USERNAME GROUPNAME instead of the described usermod command. – Byte Commander Mar 22 '16 at 14:53
  • Does the $USER need to be a member of the group vboxsf on the Host system? My understanding was that this is only necessary on the Guest system... – andrew.46 Mar 23 '16 at 05:23
  • 1
    @andrew.46 : Thank you for your comment ! Of course you have to add the user to the vboxsf group in the guest ... I thought that this a known fact, but I updated the answer to make it more clear - Thanks again ! :) – cl-netbox Mar 23 '16 at 09:01
  • @cl-netbox Thanks for your answer. I think changing the permission on the host fixed it. I already had the guest user in vboxsf group. – NRJ Mar 23 '16 at 22:34
  • 4
    why should I make the files accessible to all users on the host system with 777 just to have access in the virtual box? It seems much more to me, that something should be changed with the mounting in the guest system – Jeno Nov 22 '17 at 00:53
  • The answer below sudo mount -t vboxsf folder share -o uid=1000,gid=1000 works without changing permission of host – ch271828n Sep 23 '20 at 06:02
  • only second command required in my case – Kokizzu Jun 30 '23 at 09:19
19

No need to change main group of user - add user into group is sufficient.

sudo adduser $USER vboxsf

After the command do a restart or logout and login.

Tharok
  • 334
  • 2
  • 8
  • 2
    not enough as mount -t can only be done by root and you need it for vboxsf – Titou Mar 06 '17 at 14:53
  • 2
    Except that in some setups, mount -t is no longer needed, since the guest additions already do the mounting. In my case, this was all I had to do to get it working flawlessly, no need to change mount commands or folder permissions. – ApolloLV Mar 31 '20 at 10:41
  • For me, a restart was needed after adduser, other than that the solution worked like a charm. – Cristik Aug 31 '20 at 06:52
  • Why would adding my user to the vboxsf group do anything when the shared folder is owned by root? I did try it anyway and restarted, doesn't do anything. – Shardj Mar 20 '23 at 16:52
13

It is not necessary to change the permissions on the host system, just easily mount the shared folder for the normal user:

sudo mount -t vboxsf folder share -o uid=1000,gid=1000

1000 is the default ID of the default user. This can be checked by id username

Jeno
  • 305
2

On Ubunut 18.04 (and I thin same for 14) two question, because with proposals solutions, is not fine on too many scenarios such nginx and others.

  1. Add user to group vboxsf
  2. Add mount in /etc/fstab
  3. Verify that user has 1000 for uid and gid using id $USER
sudo usermod -aG vboxsf $USER

/etc/fstab

shared_named_in_virtual_box /home/user/point_mount_name vboxsf defaults,dmode=755,fmode=644,gid=1000,uid=1000 0 0

After reboot, if you put correct values, you have a shared mount on /home/user/point_mount_name with correct values, for chmod dirs and files, and chowned by your user.

abkrim
  • 332