sudo nano /etc/fstab helpz

Soldato
Joined
7 Jan 2007
Posts
10,607
Location
Sussex, UK
Hiya,

Code:
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/hdb1       /               ext3    errors=remount-ro 0       1
/dev/hdb5       none            swap    sw              0       0
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto     0       0
/dev/sda1       /mnt/storage1   ext3    users,auto,rw 0 0
/dev/sdb1       /mnt/storage2   ext3    users,auto,rw 0 0

How do I set file permissions of 775 for new created files and folders on storage 1 and storage2?

My issue is the same problem as this guy here: http://www.linickx.com/archives/396/bash-script-to-fix-file-permissions-recursively

He fixed his permissions problem by setting a cronjob for his permissions bash script, but I have assumed the same can be done within fstab, or am I mistaken?

Basically mediatomb (ps3 upnp streaming software) needs 775 permissions inorder to work properly but when I copy media over top my storage1/storage2 drives they are the wrong permissions and need to be changed manually, i'm basically looking for a way to do this automatically.

Hope people can help, i'm back from work at 6pm so hopefully will have some replies by then!
 
Im not sure what the linux commands are exactly, but I've set inherited permissions using ACLs on solaris before. I dont have time at the moment to look it up, but it should be possible using ACLs on linux
 
Last edited:
Pretty sure you just need to set the umask option in fstab?

umask (abbreviated from user mask) is a command and a function in POSIX environments which sets the default permission modes for newly created files and directories of the current process. When a shell or other program is creating a file or directory, it specifies the permissions to be granted. The operating system then removes from those the permissions that the umask does not allow.

And relevant fstab mounting settings:

umask=nnn, dmask=nnn, fmask=nnn
Sets the user file creation mode mask, umask, the same for directories only, dmask and for files only, fmask.

I'm pretty sure thats what you should be looking at, but i dont know the umask for 775 off the top of my head. Have to do some bitwise operations to calculate it. Also you may have to use fmask/dmask if it wont let you have a mask with executable permissions (not sure how this works).
 
Oh silly me, of course.. As you're applying the perms to the whole mount you should be able to use umask as a mount option and this will stay persistant for the duration of the mount process (i.e. as long as the disk is mounted new files get the perms)

I think 775 would be umask=002 but you may need to set directories seperatly (dmask/fmask)
 
Really cannot get my files to show anything but rw if they are created on /mnt/storage1/

What on earth am i doing wrong? please can someone help :(
 
Hi,

This is what I have done so far:

Code:
sudo addgrp media_write

sudo /etc/group

add dean,mediatomb (to media_write)

sudo chgrp media_write /mnt/storage1

sudo chmod 770 /mnt/storage1 -R

Then:

Code:
sudo chmod g=rwx /mnt/storage1/
sudo chmod g+s /mnt/storage1/

Here is my ftsab:

Code:
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/hdb1       /               ext3    errors=remount-ro 0       1
/dev/hdb5       none            swap    sw              0       0
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto     0       0
/dev/sda1       /mnt/storage1   ext3    users,auto,rw 0 0
/dev/sdb1       /mnt/storage2   ext3    users,auto,rw 0 0

This is the only settings I can get to work atm, I just need 644 on my files when they are created on /mnt/storage1/ I just cannot seem to get it, I'm about to cry!! :p

Code:
ls -l
total 8
drwxrwsr-x 5 dean media_write 4096 2009-07-17 08:10 storage1
drwxrwxr-x 5 dean media_write 4096 2009-07-17 08:12 storage2

Please can someone help me!
 
It looks like you've got into a bit of a pickle.

Just create a mountpoint with the correct permissions you want, it doesn't look like you need to go into the depth of groups as its just for yourself.

Then your fstab entry should be:

/dev/sdb1 /mnt/storage2 ext3 defaults,umask=133 0 0

You can also specify, if you wanted to go to that depth:

defaults,umask=133,gid=502,uid=502 (so files are created with userid of 502 and gid of 502)

You could then go even further and enable ACL's but that's not really needed for this :)

--------

When you're done with fstab: mount -a
 
Last edited:
If you mount with the umask set, can you see the directories if you are root? What permissions are on the directories?

I would consider removing the directories and then mounting with umask=133, then creating them again. That way they will also inherit your new mount options (the umask).
 
If you mount with the umask set, can you see the directories if you are root? What permissions are on the directories?

I would consider removing the directories and then mounting with umask=133, then creating them again. That way they will also inherit your new mount options (the umask).

ah ok, i will report back tonight. gonna take me hours to move over 700GB of data lol.
 
Back
Top Bottom