Page 1 of 1

permission of shared directory

PostPosted: 18. Apr 2008, 20:30
by Vallverdu
Hi !

I have a question about shared directory. I have a windows host and i installed a linux (redhat 5) guest.

I installed also the guest additions. Then i created a shared directory. And my problem is that only the root can write in the shared directory. Then I have to do a change user (su) before copy a file from the guest into the shared folder.

Do you know how i can change this ?

Thank you

PostPosted: 19. Apr 2008, 00:00
by Sasquatch
You can change this by changing the mount options. Read the man page of mount for the syntax of the options. You need to specify the uid and gid of your user with the mount options. If you mount the shared folder directly in your home folder, you shouldn't have these problems. However, I have seen it where there was a folder in my home that only root could access. This was the driver for my printer which I ran as root. With the uid and gid options, it will all work just fine. Don't forget to use either defaults, or the options you need too. 'man mount' is your friend. Read it carefully.

PostPosted: 20. Apr 2008, 17:35
by Vallverdu
Thank you

I mount the shared folder into my home directory and it is ok. But when i closed the root terminal it does not work any more.

I read the mount's man but i am not famous in linux and i don't understand how i have to do to specify the uid and gid of my user. If you know that can you say it to me ?

Thanks

PostPosted: 20. Apr 2008, 19:43
by Sasquatch
The GID and UID depends on your user and setup. Some have 1000 as GID and UID, others have a different number. You can check this by typing 'cat /etc/passwd' in a terminal. Find your username and there should be a number on that line. That is your UID. The GID is often the same, but to be certain, use 'cat /etc/group'. I'm not certain that it actually lists your usergroup.

PostPosted: 20. Apr 2008, 21:14
by Vallverdu
I know the user number and the group number. I chosed their when i install the OS because each user at my laboratory has a defined group and user id.

But i don't know the syntax ...

thank

PostPosted: 20. Apr 2008, 22:14
by Sasquatch
Oh, the syntax is really easy. There is a field where you set the options, it's comma separated, so use it like this:
Code: Select all   Expand viewCollapse view
mount -t vboxsf sharefolder /point/to/mount -o user,uid=1000,gid=1000,exec,rw

PostPosted: 21. Apr 2008, 10:57
by Vallverdu
I do not write user because it says that it is not a good option.

So i juste write

Code: Select all   Expand viewCollapse view
mount -t vboxsf test /home/Ger/common/ -o uid=749,gid=201,exec,rw


The name of the group and the owner are good. If I do an ls -l in the command line I see my name and my group name. But I can't write or delete anything in the folder.

PostPosted: 21. Apr 2008, 12:14
by Sasquatch
Did you set the SF to be writable? There is a checkbox that makes it read only, clear that. If that does not work, I have no idea what is the problem, it could be a bug. I don't have Linux as a Guest system, so I can't check it.
Also, the reason I added user to the options, is that the user who mounted the system can unmount it. With users, everyone can unmount the mount. If you put it in your fstab, it should load automatically.

PostPosted: 22. Apr 2008, 09:54
by Vallverdu
First thank you a lot for your help !

Did you set the SF to be writable?


I created a new folder in my home directory. If I do a ll command I see that this directory is :

Code: Select all   Expand viewCollapse view
drwxr-xr-x


Is it good ?

Also, the reason I added user to the options, is that the user who mounted the system can unmount it. With users, everyone can unmount the mount. If you put it in your fstab, it should load automatically


For this I need some precision. First I mount the shared folder when I am root. Is it ok ? The system said me that only root can use mount !

Second what I have to put in my fstab ?

Thanks

PostPosted: 22. Apr 2008, 13:29
by Sasquatch
The SF is default writable. For the fstab entry, that is about the same as what you type for mounting it manually. Mounting it is indeed a root task, but with the uid and gid options, it looks like you mounted it, not root ;). Look for the right context in fstab for the entries that are already in there, and of course the man page.
It would be something like this:
Code: Select all   Expand viewCollapse view
#Entry for Shared Folder:
sharefolder /mount/point/for/sf vboxsf auto,users,exec,rw,uid=1000,gid=1000 0 0


I did find that on my XP VM, SF is not perfect either. I have 2 VMs with XP, one crashes when I use it with a BSOD, the other can't open files correctly or write them. There is still a lot of work to be done to get it working fine.