Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

It is my first time using virtualbox and ubuntu (14.04), I am on a host Windows 7 OS.

I am trying to mount a shared folder that has files I need to access both in the virtualbox and on the windows OS. I have successfully mounted them using the vboxsf from the Guest Additions installed.

To mount I used the command sudo mount -t vboxsf <dir name in vbox> <directory in linux for example I used sudo mount -t vboxsf Test /home/user/Test

I found several ways of mounting the directories automatically upon startup using for example the /etc/rc.local method (here) where you modify said file appending the command to it (without sudo). Or by using the fstab method (here). I prefer the rc.local method personally.

Once mounted it has permissions dr-xr-xr-x however once mounted the directory is of root ownership and chown user /home/user/Test has no effect. This means I cannot make or change files in it as a normal user.

In the VirtualBox the directory to be shared is not set as read-only.

Is there a way to automatically mount the shared folder and assign ownership to my non root user?

share|improve this question

2 Answers 2

A different way to do this, if you have the guest additions installed, is to use the Virtualbox menu.
Devices > Shared Folders... Add the path, name and enable "Auto-mount" and "Make permanent" options.

Finally add your user to the group with

$sudo usermod -G vboxsf -a myusername

Groups are stored in /etc/groups, according to the usermod man page.

share|improve this answer
    
Ah I did not know this, that is useful, where are the user groups stored might I ask? –  Fiztban Jun 11 at 10:30
up vote 0 down vote accepted

Ah the curse of writing a question and then finding the answer immediately after.

I didn't use the full command suggested in this link

sudo mount -t vboxsf -o uid=$UID,gid=$GID share ~/host

So to add ownership and automatically mount in virtualbox via vboxsf in Ubuntu add to the /etc/rc.local file before the exit 0 line the command as follows:

mount -t vboxsf -o uid=1000,gid=1000 <folder name given in VirtualBox> /home/<user>/where/ever/you/want

share|improve this answer
1  
I might add that shared folders that are shared from NTFS might have some specific corner-case problems. You could work around it with losetup and chain mounting a file as a filesystem. –  hbdgaf Jun 10 at 21:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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