LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Creating an udev rule mounting all usb drive as 666 (https://www.linuxquestions.org/questions/linux-hardware-18/creating-an-udev-rule-mounting-all-usb-drive-as-666-a-807325/)

Linux.tar.gz 05-12-2010 03:42 AM

Creating an udev rule mounting all usb drive as 666
 
Hi, i need all my /media/* newly created by insertion of usb drives, chmodded 666.
I tried some tips using various threads, but i failed.
I'm on Slack 64 13.0.

smoker 05-12-2010 04:27 AM

If you chmod a directory 666 then you will not be able to open it. So why do you want to do that ?

Linux.tar.gz 05-12-2010 04:57 AM

Oh !
So 777 ?
I want all users to be able to write/read without any restriction.

catkin 05-12-2010 06:40 AM

You could write a local udev rule to make it so. The best guide to writing udev rules that I know of is here. Let us know how you get on.

smoker 05-12-2010 07:30 AM

I've been looking and it seems to be difficult to do it using udev. But I'm using Fedora, so you might have more luck.

What I've found is it is better to use udev to give a specific device a constant name, then use that to create an fstab entry, where you can specify the permissions more easily.

Of course you need to know the usb devices specifications and attributes first.


In Fedora, udev hands off all usb interaction to hal which doesn't seem to have any permissions config accessible.

Also, bear in mind that anything with a windows filesystem will be limited, because it doesn't understand permissions.

Linux.tar.gz 05-12-2010 09:17 AM

I have difficulties to set a working rule, even using the guide...
And it's not for a specific drive. Every plugged key must have 777.
I just need permission for the key root folder.

smoker 05-12-2010 09:51 AM

Well in Fedora the usb drive is always mounted as owned by the user who mounted it. So they will have to change the permissions appropriately. I can't find out where the default permissions are set. Maybe it's easier to make a udev rule that runs a script, and the script then does the chmod.

something like

Code:

KERNEL=="sd?1", DRIVERS=="usb", ACTION=="add", RUN+="/path/to/script"
This assumes your devices are being given device names under sd (sdb1, sdg1, etc)

You might try using OPTIONS+="last_rule" too.

But as I say, I can't make it work using udev. All the web resources I've found refer to an older version of Fedora where there was a 50-udev.rules which no longer exists.

Also, according to the link that catkin gave, only on some devices can you affect ownership. It doesn't specify which devices !

catkin 05-12-2010 09:56 AM

Quote:

Originally Posted by Linux.tar.gz (Post 3965773)
I have difficulties to set a working rule, even using the guide...
And it's not for a specific drive. Every plugged key must have 777.
I just need permission for the key root folder.

On reflection you want to have 777 permissions on the root folder of the file system. The actual /dev/sd<letter><number> device file just needs the normal root/disk 0660, like this
Code:

root@CW8:~# ls -l /dev/sd[ab][1-9]
brw-rw---- 1 root disk 8,  1 2010-05-12 16:22 /dev/sda1
brw-rw---- 1 root disk 8,  2 2010-05-12 16:22 /dev/sda2
brw-rw---- 1 root disk 8,  3 2010-05-12 16:22 /dev/sda3
brw-rw---- 1 root disk 8,  4 2010-05-12 16:22 /dev/sda4
brw-rw---- 1 root disk 8,  5 2010-05-12 16:22 /dev/sda5
brw-rw---- 1 root disk 8,  6 2010-05-12 16:22 /dev/sda6
brw-rw---- 1 root disk 8,  7 2010-05-12 16:22 /dev/sda7
brw-rw---- 1 root disk 8,  8 2010-05-12 16:22 /dev/sda8
brw-rw---- 1 root disk 8,  9 2010-05-12 16:22 /dev/sda9
brw-rw---- 1 root disk 8, 17 2010-05-12 16:22 /dev/sdb1
brw-rw---- 1 root disk 8, 18 2010-05-12 16:22 /dev/sdb2
brw-rw---- 1 root disk 8, 21 2010-05-12 16:22 /dev/sdb5
brw-rw---- 1 root disk 8, 22 2010-05-12 16:22 /dev/sdb6

With that set (which is default) the kernel will mount the file system in the default way and any 777 on the file system root directory is internal to the file system itself.

What is the output of /bin/ls -ld /media/* when you have some of these USB keys plugged in?

Linux.tar.gz 05-12-2010 10:18 AM

It's rw r r
I need at least rw rw r

And indeed, rules.d used to be highly populated, but now i have to set rules from scratch, which didn't worked well for now

Linux.tar.gz 05-17-2010 08:29 AM

Shoulda have tried this before... chmod 0777 /dev/media/* doesn't work.
It's impossible to change anything. It belongs to the user and the group root.
Do someone knows where this behavior is set ?

catkin 05-17-2010 09:15 AM

Quote:

Originally Posted by Linux.tar.gz (Post 3971417)
Shoulda have tried this before... chmod 0777 /dev/media/* doesn't work.
It's impossible to change anything. It belongs to the user and the group root.
Do someone knows where this behavior is set ?

It is set when the files-and-directories are created. If they belong to root then you need to have root privileges to change them, by logging on as root or by using sudo or su.

Linux.tar.gz 05-20-2010 08:16 AM

Ooops i meant /media, not /dev/media

No i can't change permission as root.

Ex. /media/KINGSTON is drwxr-xr-x
it belongs to me, and group root.
I can't change this.

Linux.tar.gz 05-20-2010 10:54 AM

Found rules are now in /lib/udev/rules.d
Added MODE="0777" @ usb line in 65-permissions.rules

/dev/sd* are now rwxrwxrwx

Still can't make /media/KINGSTON writable by all users.

Maybe should i investigate HAL ?

catkin 05-20-2010 03:13 PM

The problem may caused by how the file systems are mounted. They may be mounted read-only; that would explain why you are not able to change them despite their /dev/ files now being 777 (660 should be plenty). How are you mounting them?

Linux.tar.gz 05-21-2010 05:01 AM

It's mounted via udev/hal and Xfce volman.


All times are GMT -5. The time now is 12:31 AM.