Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to set world read/write permissions on a raw block device file (yeah, I know). I can set the permission to 666, but it goes back to 660 immediately after I touch it or write to it. Why?

[root@mysystem udev]# ll /dev/sdz6
brw-rw-rw-. 1 root disk 65, 150 Aug 30 12:09 /dev/sdz6
[root@mysystem udev]# touch /dev/sdz6
[root@mysystem udev]# ll /dev/sdz6
brw-rw----. 1 root disk 65, 150 Aug 30 13:58 /dev/sdz6
[root@mysystem udev]# chmod 666 /dev/sdz6
[root@mysystem udev]# ll /dev/sdz6
brw-rw-rw-. 1 root disk 65, 150 Aug 30 13:58 /dev/sdz6
[root@mysystem udev]#

I don't see anything in /var/log/messages, /var/log/dmesg or /var/log/secure. I turned off SELinux (setenforce 0).

edit - here's the script I wrote to fix it:

[root@mysystem rules.d]# cat /etc/udev/rules.d/99-drives.rules
KERNEL=="sd*", SUBSYSTEM=="block", MODE="0666"

[root@mysystem rules.d]# udevadm info -q path -n /dev/sdz
/devices/pci0000:80/0000:80:03.0/0000:8b:00.0/0000:8c:01.0/0000:8e:00.0/host19/rport-19:0-2/target19:0:2/19:0:2:12/block/sdz

[root@mysystem rules.d]# udevadm test /devices/pci0000:80/0000:80:03.0/0000:8b:00.0/0000:8c:01.0/0000:8e:00.0/host19/rport-19:0-2/target19:0:2/19:0:2:12/block/sdz 2>&1 | grep '99-drives'
parse_file: reading '/etc/udev/rules.d/99-drives.rules' as rules file
udev_rules_apply_to_event: MODE 0666 /etc/udev/rules.d/99-drives.rules:1
share|improve this question
2  
You probably want to look at writing a udevd rules.d set that makes MODE=0666. I assume udev is overwriting this 'for you'. –  polynomial Aug 30 '11 at 19:37
    
Yeah, I just created a simple udev rule that seems to work. Documentation was not helpful, but I was able to google around and stitch together enough examples. I would post my script, but this site is forcing me to wait a day to post my answer because I don't have enough reputation. –  twblamer Aug 30 '11 at 19:49
add comment

1 Answer

up vote 3 down vote accepted

Setting permissions in udev manually will almost never work. You should really look at adding a rule in /etc/udev that will set "MODE=0666" on the device in question. That will make it so the system creates it that way.

(adding per comment discussion)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.