Changing permissions for the sf_ folders

Discussions about using Linux guests in VirtualBox.
TruClueless
Posts: 8
Joined: 29. Sep 2016, 11:16

Changing permissions for the sf_ folders

Post 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.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Changing permissions for the sf_ folders

Post 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".
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Changing permissions for the sf_ folders

Post 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.
TruClueless
Posts: 8
Joined: 29. Sep 2016, 11:16

Re: Changing permissions for the sf_ folders

Post 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.
Attachments
Clipboard01.jpg
Clipboard01.jpg (49.66 KiB) Viewed 16609 times
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Changing permissions for the sf_ folders

Post 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.
TruClueless
Posts: 8
Joined: 29. Sep 2016, 11:16

Re: Changing permissions for the sf_ folders

Post 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"
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Changing permissions for the sf_ folders

Post 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.
TruClueless
Posts: 8
Joined: 29. Sep 2016, 11:16

Re: Changing permissions for the sf_ folders

Post 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.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Changing permissions for the sf_ folders

Post 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.
Martin
Volunteer
Posts: 2562
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: Changing permissions for the sf_ folders

Post 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.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Changing permissions for the sf_ folders

Post 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.
TruClueless
Posts: 8
Joined: 29. Sep 2016, 11:16

Re: Changing permissions for the sf_ folders

Post 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)
Attachments
Clipboard03.jpg
Clipboard03.jpg (19.04 KiB) Viewed 16595 times
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Changing permissions for the sf_ folders

Post 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?
TruClueless
Posts: 8
Joined: 29. Sep 2016, 11:16

Re: Changing permissions for the sf_ folders

Post 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.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Changing permissions for the sf_ folders

Post 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
Post Reply