25

I'm trying to recursively chown a VirtualBox shared folder, but I can't get it to work:

$ ls -lah
total 16K
drwxr-xr-x  4 root root   4.0K Aug  1  2012 .
drwxr-xr-x 23 root root   4.0K Jul 21  2012 ..
drwxrwx---  1 root vboxsf 4.0K May  4 17:02 sf_dev
drwxrwx---  1 root vboxsf 4.0K Sep  2 10:21 sf_dropbox
$ sudo chown -R pknight:pknight sf_dropbox && ls -lah
total 16K
drwxr-xr-x  4 root root   4.0K Aug  1  2012 .
drwxr-xr-x 23 root root   4.0K Jul 21  2012 ..
drwxrwx---  1 root vboxsf 4.0K May  4 17:02 sf_dev
drwxrwx---  1 root vboxsf 4.0K Sep  2 10:21 sf_dropbox

I'm aware that I could just add a user to the vboxsf group (as it has full permissions), but I don't want to give every user/daemon full permissions to all of my shared folders.

I'm running VirtualBox 4.2.x, with Windows 7 as the host and both Xubuntu and Debian as guests.

Is there any way for me to change the owner/group of my VirtualBox shared directory?

  • 1
    Note that the accepted answer doesn't answer the question, and it's that question that I need an answer to. – reinierpost Mar 22 '16 at 17:58
27

The VirtualBox shared file system (vboxsf) doesn't support POSIX permissions per se; rather, they are "set" at mount time:

$ mount
...
dropbox on /media/sf_dropbox type vboxsf (gid=1001,rw)

The gid bit specifies the group that owns the directory; on my system, this happens to correspond with the vboxsf group.

You can alter the user and/or group ownership by remounting (must be done as root):

# mount -t vboxsf -o remount,gid=1000,uid=1000,rw dropbox /media/sf_dropbox

Replace 1000 with the desired user/group IDs, and dropbox with the name of the share (the part after sf_).

Note that this must be done after every reboot unless you edit /etc/fstab.

  • How to you edit fstab to do this? – TheSmose Nov 25 '15 at 19:29
  • @TheSmose see askubuntu.com/questions/252853/… for details about how to do this in Ubuntu (and probably other Debian-based distros as well). In the <options> field you'll most likely want to put gid=1000,uid=1000,rw (replace the user/group IDs as appropriate). – nc4pk Nov 26 '15 at 2:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.