Page 1 of 2

Changing permissions for the sf_ folders

Posted: 29. Sep 2016, 11:25
by TruClueless
Hello,

I have installed the Ubuntu server 16.04 (along with guest additions) as a guest OS on my windows machine.
In the Virtualbox settings I have added a shared folder with the name "Music" and set it to be permanently and automatically mounted by checking the two check boxes.

When I boot up the Ubuntu, the Music folder is correctly mounted as /media/sf_Music.

The problem is that I am unable to change any permissions for that folder, which is set to 770 by default.
I tried commands such as "sudo chmod 777 /media/sf_Music". The command executes with no error, but when I check the permissions on sf_Music, they are still 770.
When I try to use the ACLs (setfacl) on sf_Music, then I get the operation invalid error (it works fine on other folders).

Why isn't it working? Now, I realize that I cannot use things like chmod on the actual files which are inside of the sf_Music, since those files are residing on the actual windows machine, which doesn't support the permission scheme, but I am not trying to change perms on those files, I only want to change them on the sf_Music directory itself.

Re: Changing permissions for the sf_ folders

Posted: 29. Sep 2016, 11:55
by socratis
From this thread (read all of it): viewtopic.php?f=7&t=10535
Sasquatch wrote:The chmod options only work on Linux native file systems (ext2/3/4, reiserfs, etc). The VB shared folders are not a native file system, so you can't change it. You can't change the file mode on an NTFS or FAT partition either, you have to change the mount options for it. The exec option means that all files will have the execute bit enabled, as I stated above. There is something with the SF module that makes all files you create on the Guest have x00 file modes, where x depends on the mount options used (if you omit exec, it will be 600, else 700).
You also get great results by searching for "change shared folders permissions site:virtualbox.org".

Re: Changing permissions for the sf_ folders

Posted: 29. Sep 2016, 14:45
by Perryg
You will find permission issues using the automount feature as they are handled differently in removable media by the OS. Remove the automount and use a standard mount instead with the options flag and set you required permissions there.

Example:

Code: Select all

sudo mount -t vboxsf -o rw,uid=1000,gid=1000 share ~/host
Replace uid, gid with your uid, gid, and ~/host with the actual mount point

You can add this statement to the /etc/rc.local or /etc/fstab if rc.local has been removed from your distro to mount it at boot.

Re: Changing permissions for the sf_ folders

Posted: 30. Sep 2016, 15:39
by TruClueless
Perryg wrote:You will find permission issues using the automount feature as they are handled differently in removable media by the OS. Remove the automount and use a standard mount instead with the options flag and set you required permissions there.

Example:

Code: Select all

sudo mount -t vboxsf -o rw,uid=1000,gid=1000 share ~/host
Replace uid, gid with your uid, gid, and ~.host with the actual mount point

You can add this statement to the /etc/rc.local or /etc/fstab if rc.local has been removed from your distro to mount it at boot.
Thank you. This seems to be working and monting as 777 with this command, so that is exactly what i want.
sudo mount -t vboxsf -o rw myshare /home/me/share (this works no problem)

But there is a problem. I wanted to automate the process, so I won't have to mount manually every time after I reboot, so I edited the /etc/fstab and added a new line
myshare /home/me/share vboxsf defaults 0 0
(Look at the picture to see what the fstab file looks like now)
But if i restart the computer now, it won't boot anymore. Instead it will boot only into an emergency mode.

Re: Changing permissions for the sf_ folders

Posted: 30. Sep 2016, 15:47
by Perryg
Why didn't you use /etc/rc.local?
It is possible to use fstab but you have to get it right. Remove the line from fstab in recovery mode and put the mount statement in rc.local just above the exit line, reboot and see what happens.

Re: Changing permissions for the sf_ folders

Posted: 30. Sep 2016, 18:28
by TruClueless
Perryg wrote:Why didn't you use /etc/rc.local?
It is possible to use fstab but you have to get it right. Remove the line from fstab in recovery mode and put the mount statement in rc.local just above the exit line, reboot and see what happens.
I followed the official virtualbox tutorial for manual mounting here:
https://www.virtualbox.org/manual/ch04. ... unt_manual

Anyway, I removed the line from fstab and added the sudo mount -t vboxsf -o rw myshare /home/me/share into the rc.local file. It still doesn't work. During boot it says "Failed to start rc.local"

Re: Changing permissions for the sf_ folders

Posted: 30. Sep 2016, 18:54
by Perryg
My friend you failed on two fronts. First system level scripts that run at boot do not need sudo so remove that. You also failed to give your user id and gid as stated in the example I gave you.

Run id from the hosts terminal to see what your uid and gid are.

Re: Changing permissions for the sf_ folders

Posted: 30. Sep 2016, 19:39
by TruClueless
Perryg wrote:My friend you failed on two fronts. First system level scripts that run at boot do not need sudo so remove that. You also failed to give your user id and gid as stated in the example I gave you.

Run id from the hosts terminal to see what your uid and gid are.
I added id and guid and removed sudo and it still doesn't work. But I don't think those were the problem anyway, since I can run the mount command manually without specifying the ids, and a root id is used automatically in that case, but like I said, even after specifying the IDs it doesn't work. Maybe the rc.local file gets executed too soon, before the guest additions run, so the OS doesn't know the share name I am using there yet, and that is why it works when i run it manually, but not when placed into rc.local.

Re: Changing permissions for the sf_ folders

Posted: 30. Sep 2016, 19:47
by Perryg
Post the /etc/rc.local file here so I can take a look.

I also need you to post the exact share name you gave this share and the exact mount location you are using.

Re: Changing permissions for the sf_ folders

Posted: 30. Sep 2016, 19:50
by Martin
You could try to add a sleep of a few seconds in rc.local before the mount command to give the system more time to start the vbox modules.

Re: Changing permissions for the sf_ folders

Posted: 30. Sep 2016, 19:56
by Perryg
Martin wrote:You could try to add a sleep of a few seconds in rc.local before the mount command to give the system more time to start the vbox modules.
Yes but IIRC this is not really needed in 16.04, at least I didn't need it. Debian 8 for sure needs it. Once I see their rc.local and other information I will construct one with and one without so they can have them both.

Re: Changing permissions for the sf_ folders

Posted: 30. Sep 2016, 20:55
by TruClueless
Perryg wrote:Post the /etc/rc.local file here so I can take a look.

I also need you to post the exact share name you gave this share and the exact mount location you are using.
This is the rc.local file.
The share name in virtualbox settings is "fotky" (I have the share name correct, since it works if I mount manually) and the mount location is the folder "fotky" which i created in the home directory of the user dasa, so /home/dasa/fotky.
(Also, in the command, I haven't just copied the uid and gid you posted, 1000 is actually my user id too)

Re: Changing permissions for the sf_ folders

Posted: 30. Sep 2016, 21:02
by Perryg
Try adding the following just before your mount "sleep 10 && "

Code: Select all

sleep 10 && mount -t vboxsf -o rw,uid=1000,gid=1000 fotky /home/dasa/fotky
Also make sure the execution bit is set on the file. I see you are also running a service networking restart. What is the reason for this?

Re: Changing permissions for the sf_ folders

Posted: 30. Sep 2016, 21:35
by TruClueless
Perryg wrote:Try adding the following just before your mount "sleep 10 && "

Code: Select all

sleep 10 && mount -t vboxsf -o rw,uid=1000,gid=1000 fotky /home/dasa/fotky
Also make sure the execution bit is set on the file. I see you are also running a service networking restart. What is the reason for this?
Still not working. This is a mystery to me. All the rc.local does is, it executes the command the same way as if I entered it manully, is it not? Yet if I mount it manually it works.

The networking restart has to be there otherwise the internet isn't working (don't ask me why, I have no idea..). But the file is definitely executing, because if the networking restart wasn't getting executed, the internet would not be working.

Re: Changing permissions for the sf_ folders

Posted: 30. Sep 2016, 22:50
by Perryg
Post the results of the following.

Code: Select all

ls -al /etc/rc.local
Then I would like you to comment out the service restart ( place # at the front of the line ) and reboot