LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 11-16-2006, 09:19 AM   #1
swampdog2002
Member
 
Registered: Jul 2005
Distribution: Slackware 12.2, 13.0, openSUSE 11.2
Posts: 397

Rep: Reputation: 33
udev rules Slackware 11


Hello all,
I've been reading the document that many here have referred others to when creating udev rules. I have looked at this myself, but am somewhat confused as to how to apply this to Slackware 11. Basically, what I want to accomplish is the following:
  • create link to /dev/hdc using /dev/dvd-rom
  • create link to /dev/hdd using /dev/dvd-rw
  • create link from /dev/ttyS4 to /dev/modem

I am not sure where the main file that creates these udev rules in Slackware 11 is located, or if I have to create a new one to use. I would like to edit the existing one using the above links. Each time I create a symbolic link manually, it is gone after rebooting, which is something that I suppose udev does. Any information is appreciated. Thanks.
 
Old 11-16-2006, 09:42 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
Writing udev rules

Is this the page you've been looking at? To quote from it:

Quote:
Default udev rules are stored in /etc/udev/rules.d/50-udev.rules. You may find it interesting to look over this file - it includes a few examples, and then some default rules proving a devfs-style /dev layout. However, you should not write rules into this file directly.

Files in /etc/udev/rules.d/ are parsed in lexical order, and in some circumstances, the order in which rules are parsed is important. In general, you want your own rules to be parsed before the defaults, so I suggest you create a file at /etc/udev/rules.d/10-local.rules and write all your rules into this file.

In a rules file, lines starting with "#" are treated as comments. Every other non-blank line is a rule. Rules cannot span multiple lines.
(emphasis mine)

and

Quote:
In order to preserve the standard /dev layout, your own rules will typically leave the NAME alone but create some SYMLINKs and/or perform other assignments.

KERNEL=="hdc", SYMLINK+="cdrom cdrom0"

The above rule is probably more typical of the types of rules you might be writing. It creates two symbolic links at /dev/cdrom and /dev/cdrom0, both of which point at /dev/hdc. Again, no NAME assignment was specified, so the default kernel name (hdc) is used.
That should be pretty much all you need to know for what you want to do. If there are any differences between this and slack you should be able to figure them out pretty easily.

Good luck.
 
Old 11-16-2006, 10:52 AM   #3
swampdog2002
Member
 
Registered: Jul 2005
Distribution: Slackware 12.2, 13.0, openSUSE 11.2
Posts: 397

Original Poster
Rep: Reputation: 33
Thanks for the reply. When I originally utilized this document, I did not have a 50-udev.rules file on my machine in the place that was specified within the document. I was going to look in there to see how the rules were setup prior to creating my own. I thought that rules that were already set up might collide with the ones that I was trying to create. Before 11, I did not bother with udev, but it seems to be an integral part of this new release. It seems pretty straightforward enough, so I'll see what I can come up with. Thanks.

Last edited by swampdog2002; 11-16-2006 at 10:53 AM.
 
Old 11-16-2006, 11:51 AM   #4
hussar
Member
 
Registered: Oct 2003
Location: Heidelberg, Germany
Distribution: Slackware 11.0; Kubuntu 6.06; OpenBSD 4.0; OS X 10.4.10
Posts: 345

Rep: Reputation: 30
That "Writing udev rules" site gets cited pretty often here in threads discussing udev, and for good reason.

One thing that bothers me a little though is the repeated reference to the statement that udev rules are in /etc/udev/rules.d/50-udev.rules. In slackware, they're not. At least they haven't been in udev-064, udev-071, or (the current version) udev-097. They are in /etc/udev/rules.d/udev.rules. So, if you want to bring your slack in line with the udev rules site, you need to move /etc/udev/rules.d/udev.rules to /etc/udev/rules.d/50-udev.rules and then write your own /etc/udev/rules.d/10-udev.rules.
 
Old 11-16-2006, 12:05 PM   #5
swampdog2002
Member
 
Registered: Jul 2005
Distribution: Slackware 12.2, 13.0, openSUSE 11.2
Posts: 397

Original Poster
Rep: Reputation: 33
If I create my own udev rules in /etc/udev/rules.d and call the file 10-udev.rules as cited within the document, will udev still continue to load the original /etc/udev/rules.d/udev.rules as well, thereby overwriting the udev rules that were created by me? This is something that concerns me, but when I get the opportunity I shall find out with a trial-and-error session on my machine. I can always create a backup of the original udev.rules file and edit this directly, although this appears to be frowned upon by the documentation.
 
Old 11-17-2006, 08:21 AM   #6
swampdog2002
Member
 
Registered: Jul 2005
Distribution: Slackware 12.2, 13.0, openSUSE 11.2
Posts: 397

Original Poster
Rep: Reputation: 33
I was able to successfully create my own udev rules by creating a file in /etc/udev/rules.d/10-udev.rules as the document explained and, for the most part, it seemed to work as expected. I had to manually edit the main udev.rules file for the floppy drive since, for some reason, I was receiving a message at startup stating that the link /dev/fd0 could not be created since it already existed. I don't know exactly how udev works, but other links for optical drives seemed to worked w/o any problems, but just commenting out a specific line (don't remember offhand) in udev.rules and creating my own rule seem to resolve this. The rules that I created were:

KERNEL=="fd0", SYMLINK+="floppy"
KERNEL=="hdc", SYMLINK+="dvd-rom"
KERNEL=="hdd", SYMLINK+="dvd-rw"

I don't know if these are necessarily ideal, but they seem to work for me.

Last edited by swampdog2002; 11-17-2006 at 08:23 AM.
 
Old 11-17-2006, 01:52 PM   #7
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
Glad to hear you got it to work.

As for the file names, AIUI, the primer page states that udev reads the config files in lexical order. so 10-udev.rules will be read before 50-udev.rules, and 50-udev.rules will be read before udev.rules. But every .rules file in the directory will be scanned in the end. So you slack users can rename the udev.rules if you want, or not, since either way it won't affect the loading order as long as you ensure that the local rules file has a lower alphanumeric sequence than the main one.

As for the floppy problem, perhaps the fact that the system needs a floppy drive at boot has something to do with it. I'm guessing the bootup process creates the fd0 device even before udev starts, so it naturally freaks out when it tries to create a device that's already there. Did udev go ahead and create the symlink in that case, or did the rule fail completely?
 
Old 11-17-2006, 02:26 PM   #8
swampdog2002
Member
 
Registered: Jul 2005
Distribution: Slackware 12.2, 13.0, openSUSE 11.2
Posts: 397

Original Poster
Rep: Reputation: 33
Before I created my own udev rule for the floppy drive, and commented out the line in /etc/udev/rules.d/udev.rules, I would get a message stating that creation of /dev/fd0 failed due to the fact that this link already existed. I actually deleted both /dev/fd0 while logged in, and then rebooted. I still received the same message at startup, so perhaps something else was creating the /dev/fd0 link prior to udev, as you mentioned. However, with the rule that I created, it seems to be working alright, so I believe that I'll just leave it as is unless something else needs to be done.
 
Old 11-17-2006, 04:38 PM   #9
urka58
Member
 
Registered: Nov 2003
Distribution: slackware 14
Posts: 530

Rep: Reputation: 30
Put this in you 10-udev.rules
# Floppy
KERNEL=="fd0", BUS=="platform", NAME="%k", SYMLINK+="floppy", GROUP="floppy", MODE="0660", OPTIONS+="last_rule"

Ciao
 
Old 11-17-2006, 07:06 PM   #10
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 3,443

Rep: Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852
If you want to create a link from /dev/ttyS4 to /dev/modem at boot up, add a symlink in the /lib/udev/devices directory using this command.
ln -s /dev/ttyS4 modem

ls -l modem should then give an output like this.
lrwxrwxrwx 1 root root 10 2006-11-02 00:49 modem -> /dev/ttyS4
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating rules for udev wnaLinux Slackware 5 01-03-2008 09:21 AM
slackware-current, udev 0.96, and custom udev rules not working rignes Slackware 6 08-10-2006 03:43 AM
UDEV Rules Location Toods Slackware 1 04-28-2006 02:23 AM
need help fixing my udev rules or ivman rules hedpe Linux - Hardware 2 03-18-2006 10:07 AM
Networking rules (udev) cassi0peias Linux - Networking 1 10-18-2005 10:13 AM


All times are GMT -5. The time now is 12:00 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration