Saturday, November 05, 2011

Mounting VirtualBox shared folder that is writeable by non-root user

I have been using VirtualBox for awhile now but I mostly use Windows as the host machine. I just had setup few Linux boxes as VirtualBox host and found a need to save files in the host as I normally do snapshots and clean 'em up.

Mounting a shared folder is easy, what caught me was that I can't change ownership of the folder created under the shared folders. So my regular user account can't create files.

I realized that mount actually accepts options as to who would have access to the mounted folder, so to mount with read/write access to a user, do:

sudo mount -t vboxsf -o rw,uid=1000 userdat /mnt/userdat
Where:
uid=1000 is the user ID of the user. For example, I have a user named timus, to get the ID, you can do:

timus@ubu1110:~$ cat /etc/passwd | grep timus
timus:x:1000:1000:timus,,,:/home/timus:/bin/bash

As can be seen, timus uid is 1000 and group ID is 1000 as well.

userdat is the VirtualBox shared folder name.
/mnt/userdat is the mount point

Keywords for easy search:
user userland VirtualBox shared folders read write

4 comments:

Tina said...

Thanks so much! I was having trouble changing the owner of my mounted directory and this was exactly what I needed :o)

Techno Scavenger said...

I am glad to be of help. Thanks for the comment.

tscharst said...

Yeah, now I can work with shared folders in VirtualBox, thanks!

Anonymous said...

Thanks so much, this worked like a charm.

How to configure nfs server on QNX 7.1

How to configure nfs server on QNX 7.1 Target: QNX 7.1 running on a VM (VMware Workstation or VirtualBox). It is assummed that the targets ...