Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am using ubuntu 10.04 LTS - Locid Lynx. I have a requirement to set specific group and permissions for any usb stick file/directories on mount. I have tried overwriting the udev rules. Here is what I have done:

  1. Created 99-test.rules under /etc/udev/rules.d/ directory with content as SUBSYSTEMS=="usb",GROUP="tomcat6",MODE="0777",NAME="test"
  2. sudo service udev restart

Now when I mount the usb stick and run 'sudo blkid', it prints

/dev/test: UUID="002A-0AA5" TYPE="vfat"

But the ls -l /media/ gives back

drwx------ 4 admin admin 8192 1969-12-31 16:00 002A-0AA5

It seems that above rule from 99-test.rules is getting applied but getting overwritten afterwards, thus changing group and permissions back to some default value. What is it I am missing here? Do I have to change anything else?

share|improve this question
    
An aside: I gather from the name that you are testing this rule, but before you actually put it in place you might want to add something like KERNEL=="sd?1" so it does only apply to USB storage devices (and not cameras, audio devices, etc). –  John S Gruber Aug 13 '12 at 17:36

2 Answers 2

Try to add ACTION=="add" as trigger for that rule.

share|improve this answer

This works for me:

SUBSYSTEMS=="usb",KERNEL=="sd?1",GROUP="adm",MODE="0777",SYMLINK+="test"
  • I don't know why, but ACTION== stopped the rule from working at all.

  • The kernel rule was necessary to avoid a conflict between the stick and the stick's partition, I suspect that was the problem you were seeing.

  • The symlink is to get rid of an error message about a conflict between the kernel device name and the rule device name. You get a /dev/test that has a symlink to /dev/sdb1, or such.

On 12.04 restarting udev wasn't necessary when testing the rule. Error messages were logged at /var/log/syslog, so I used tail -f /var/log/syslog as I mounted the USB drive to watch for them.

You may wish to add more tests so you can limit your rule to just the drive(s) you want /dev/test to map to in case you might plug a camera or other device in simultaneously with you memory stick.

share|improve this answer

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.