-   Slackware (
-   -   First UDEV Rule, Not quite there ... (

orbit 02-18-2009 10:49 PM

First UDEV Rule, Not quite there ...
I am trying to build a udev rule that will enable all floppy devices and usb devices to automatically have full r/w/x access allowed to everyone.

This is my first attempt at a udev rule, so please be patient.

I have started on this document : and am moving through it.

What I have made so far (in /etc/udev/rules.d/98-local-rules) is the following:


KERNEL=="sd[0-9]*", NAME="sd/%n", SYMLINK+="%k", GROUP="plugdev", MODE="0666"
KERNEL=="sd[0-9]*", OWNER="user", MODE="0666"
KERNEL=="fd[0-9]*", NAME="fd/%n", SYMLINK+="%k", GROUP="floppy", MODE="0666"
KERNEL=="fd[0-9]*", OWNER="user", MODE="0666"

Unfortunately, after a reboot, this seems to have had no effect whatsoever on my fd*/sd* permissions.

So, before I get lost on a wrong tangent; can anyone offer firstly confirmation that I am on the right path with this syntax, and secondly a pointer in where I went wrong with it?

Thanks for any positive advice :)

DavidHindman 02-18-2009 11:34 PM

I'm not an expert, but I wrote some udev rules a couple of weeks ago.

I think man udev gives some critical information that's not in the document you cited.

There are two sets of udev rules. The default set of rules is in /lib/udev/rules.d/. The custom rule set is in /etc/udev/rules.d/.

If your custom udev rules seem to have no effect, maybe your custom rules are failing to override the default udev rules in /lib/udev/rules.d/.

For example, the floppy devices fd* are created in /lib/udev/rules.d/50-udev-default-rules. In order to override those rules, your custom rules file would need to be in /etc/udev/rules.d/ 50-udev-default-rules.

Anyway, take a look at the man page for udev and see if you are properly taking into account the existence of the default rules already in /lib/udev/rules.d/.

orbit 02-19-2009 01:15 AM

Hi DavidHindman, thanks for your response.

I know what you mean about 'master' rules not allowing user rules to be run, but after looking ... I don't have a /lib/udev/rules.d/ directory? Are you using Slackware .. or another Linux?

So anyway I scrapped the first attempt and tried again, this time I created:


BUS=="usb", KERNEL="sd[a-z][1-9]",NAME="sd/%n", SYMLINK+="%k", GROUP="users", Mode=="0777"
KERNEL=="sd[0-9]*", OWNER="user", MODE="0777"
BUS=="floppy", KERNEL=="fd[0-9]*", NAME="fd/%n", SYMLINK+="%k", GROUP="users", MODE="0777"
KERNEL=="fd[0-9]*", OWNER="user", MODE="0777"

I saved this in /etc/udev/rules.d/98-local.rules ... then rebooted.

Result is that absolutely nothing has changed? USB and floppies are still mounting [ user - root : drwxr-xr-x ] :(

Am I missing something here? Why after two attempts has nothing changed (for good or bad)? Am I working on the right file?

Right now I am having a very hard time getting my head around these (seemingly thousands) of Options and Variables in UDEV syntax, and am quite confused as to what is the correct way to go.

So if anyone can shed some light as to whether I am even remotely on track .. or ... way out of the ballpark, I would really appreciate it.

Thanks very much for any assistance.



DavidHindman 02-19-2009 01:53 AM


Originally Posted by orbit (Post 3449186)
Are you using Slackware?

Yes, Slackware 12.2. I should have specified the version. Maybe yours is different.


root@barsoom:~# ls /lib/udev/rules.d/
40-alsa.rules          60-persistent-input.rules          80-drivers.rules
40-infiniband.rules    60-persistent-storage-tape.rules  80-libnjb.rules
40-isdn.rules          60-persistent-storage.rules        80-libpisock.rules
40-slackware.rules    60-persistent-v4l.rules            80-libsane.rules
40-zaptel.rules        61-persistent-storage-edd.rules    90-hal.rules
50-udev-default.rules  64-device-mapper.rules            90-libgphoto2.rules
55-hpmud.rules        65-permissions.rules              90-libmtp.rules
60-bluetooth.rules    75-cd-aliases-generator.rules      90-network.rules
60-cdrom_id.rules      75-persistent-net-generator.rules  95-udev-late.rules
60-pcmcia.rules        79-fstab_import.rules              99-fuse.rules
root@barsoom:~# ls /etc/udev/rules.d
40-alsa.rules  40-alsa.rules~  70-persistent-cd.rules  70-persistent-net.rules

What I've done here is put my new udev rules in /etc/udev/rules.d/40-alsa.rules. This overrides the file of the same name in the /lib/udev/rules.d/ directory.

I think you have "KERNEL=" instead of "KERNEL==" in the first rule of your second attempt, also "MODE==" instead of "MODE=" in the same rule. Every little bug adds up.

titopoquito 02-19-2009 02:03 AM

I'm not absolutely sure, but I think your problem is that the underlying device node has not the permissions you want. It probably won't help to create just a symlink with other permissions if the real node has other ones.
That said I guess you have to change udev's default rules. Mine (Slackware 12.1) are in /etc/udev/rules.d/50-udev-default.rules, yours should AFAIK be in /lib/udev/rules.d if you are running Slackware 12.2. Look there for the floppy and sd* node creation and change it to your needs ... (to make a copy of this file first is a good idea)

DavidHindman 02-19-2009 02:42 AM


Originally Posted by orbit (Post 3449055)
...What I have made so far (in /etc/udev/rules.d/98-local-rules) is the following...

For the version of udev on Slack 12.2, a rule file must end with the extension .rules

That is, for my version of udev, the file "98-local-rules" would have to be named "98-local-rules.rules", else it would have no effect.

I took your floppy rule and put it into my /etc/udev/rules.d/98-local-rules.rules. I also changed it to generate devices named /dev/xfd* instead of /dev/fd*, so I could isolate the effect of your new rule. It sort of worked, giving the 666 permissions you intended. The device name came out as /dev/xfd/0 instead of /dev/xfd0, but it's close!


root@barsoom:~# ls -l /dev/xfd/0
brw-rw-rw- 1 root floppy 2, 0 2009-02-19 02:30 /dev/xfd/0

orbit 02-19-2009 05:38 PM

Hi all,

Thanks for all the great pointers and assistance, I really appreciate it.

I'll get back to this project tonight after work, to see if I can finalise it.

Results of further attempts pending ...

Cheers :)

orbit 02-22-2009 10:08 PM

Hi all,

Well after many attempts at setting this usb/floppy rwx rule, I seem to still be having no effective progress.

My latest attempts have included:


# disk devices
KERNEL=="sd*",          NAME="%k", GROUP="disk", Mode="0777"
KERNEL=="ataraid*",    NAME="%k", GROUP="disk", Mode="0777"

# permissions for IDE floppy devices
SUBSYSTEMS=="ide", KERNEL=="*[!0-9]", ENV{DRIVER}=="ide-floppy*", NAME="%k", GROUP="floppy", MODE="0777"

# put all removable devices in group "plugdev"
KERNEL=="hd*[!0-9]", ATTR{removable}=="1", GROUP="plugdev", Mode="0777"
KERNEL=="hd*[0-9]", ATTRS{removable}=="1", GROUP="plugdev", Mode="0777"
KERNEL=="sd*[!0-9]", ATTR{removable}=="1", GROUP="plugdev", Mode="0777"
KERNEL=="sd*[0-9]", ATTRS{removable}=="1", GROUP="plugdev", Mode="0777"

BUS=="usb", KERNEL=="sd[a-z][1-9]", SYMLINK+="%k", GROUP="plugdev", Mode="0777" #, NAME="sd%n",
KERNEL=="sd[0-9]*", OWNER="user", MODE="0777"
BUS=="floppy", KERNEL=="fd[0-9]*", SYMLINK+="%k", GROUP="floppy", MODE="0777" # , NAME="fd%n",
KERNEL=="fd[0-9]*", OWNER="user", MODE="0777"

which I removed and then tried ....


# disk devices
KERNEL=="sd*",          NAME="%k", OWNER="user", GROUP="users", Mode="0777"
KERNEL=="ataraid*",    NAME="%k", GROUP="disk", Mode="0777"

# permissions for IDE floppy devices
SUBSYSTEMS=="ide", KERNEL=="*[!0-9]", ENV{DRIVER}=="ide-floppy*", NAME="%k", OWNER="user", GROUP="users", MODE="0777"

# put all removable devices in group "users"
KERNEL=="hd*[!0-9]", ATTR{removable}=="1", OWNER="user", GROUP="users", Mode="0777"
KERNEL=="hd*[0-9]", ATTRS{removable}=="1", OWNER="user", GROUP="users", Mode="0777"
KERNEL=="sd*[!0-9]", ATTR{removable}=="1", OWNER="user", GROUP="users", Mode="0777"
KERNEL=="sd*[0-9]", ATTRS{removable}=="1", OWNER="user", GROUP="users", Mode="0777"

BUS=="usb", KERNEL=="sd[a-z][1-9]", SYMLINK+="%k", OWNER="user", GROUP="users", Mode="0777"
KERNEL=="sd[0-9]*", OWNER="user", GROUP="users", MODE="0777"
BUS=="floppy", KERNEL=="fd[0-9]*", SYMLINK+="%k", OWNER="user", GROUP="users", MODE="0777"
KERNEL=="fd[0-9]*", OWNER="user", GROUP="users", MODE="0777"

But so far this seems to have had no effect on the 'real world' /read/write/execute permissions and ownerships of these devices.



/dev/sda1 on /media/512_Cruzer type vfat (rw,nosuid,nodev,noatime,flush,uid=1000,utf8,shortname=lower)


ls -l /dev/sda1
brwxrwxrwx 1 user plugdev 8, 1 2009-02-23 13:25 /dev/sda1


ls -l /media/512_Cruzer
total 5488
-rwxr-xr-x 1 user root 5619080 2009-02-16 13:38 Opera_963_en_Setup.exe

As you can see from the above code, the /dev's are now getting the correct permissions that I have set, but their corresponding /media mountpoints still retain the original permissions (which are no good).

Can anyone offer a suggestion as to how I can make a systemwide policy of making these user (vfat) floppy and USB mountpoints automatically default to rwx for all users?

(Please don't mention fstab as I need this to be done automatically via UDEV/HAL/DBUS? as devices are inserted by the user; without requiring user intervention, or (su)root access editing).

p.s. I'm currently working on a Slackware 12.0.0 system, but would like to migrate this (rule/policy?) [once I get it working] to multiple Slackware 12.1.0 and Slackware 12.2.0 systems.

Appreciation for all positive comments.



All times are GMT -5. The time now is 11:03 AM.