Why can't I chown a VirtualBox shared folder?

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.


These are the steps I followed, to get my shared folder to behave as expected:

Shared Folder Setting

Host

Add Shared Folder

Add Shared Folder

Reboot the guest.

Allow soft links

VBoxManage setextradata <guest vm> VBoxInternal2/SharedFoldersEnableSymlinksCreate/<shared folder> 1


Guest

Update guest additions

Devices -> Insert Guest Editions CD Image

add all necessary users to the vboxsf group

sudo usermod -a -G vboxsf <username>

Change permissions

sudo chown -R <username>:<user group> /media/

Reboot the system.

Change ownership

sudo mount -t vboxsf -o gid=<username>,uid=<user group>,rw <share folder name> /media/sf_<share folder name>

This is the corresponding line in /etc/fstab:

data /media/sf_data vboxsf rw,nodev,relatime,iocharset=utf8,uid=982,gid=982 0 0

Note: I'm still unable to change ownership to a random user on the shared folder.