LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 03-12-2013, 05:53 PM   #1
farnsy
LQ Newbie
 
Registered: Nov 2008
Location: Pennsylvania
Distribution: Fedora 19
Posts: 24

Rep: Reputation: 2
How does one change a system udev rule permanently?


I'm running Fedora 18 and the udev rule /usr/lib/udev/rules.d/60-cdrom_id.rules has a "feature" in it that prevents me from disabling the hardware button on my cdrom drive (ordinarily I would do so using 'eject -i 1'). My toddler keeps pressing my eject button and driving me crazy.

I can edit the file and change it so eject behaves correctly but there's a big warning at the top of the file that says "do not edit this file, it will be overwritten on update." I have noticed that it has indeed been overwritten a few times with updates and I get bugged with going in and fixing it all the time.

If one isn't supposed to edit the files in /usr/lib/udev/rules.d by hand, where is it that one can modify what gets written to them?

Alternate solutions would be great as well. At present my top idea is to keep a copy of the file (edited) around somewhere and have a cron job overwrite the version in /usr/lib/udev/rules.d periodically. Not very elegant.
 
Old 03-12-2013, 05:57 PM   #2
Emerson
Senior Member
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~
Posts: 3,177

Rep: Reputation: Disabled
Create 61-cdrom_id.rules? As a custom rule it should not be overwritten.
 
Old 03-12-2013, 06:35 PM   #3
farnsy
LQ Newbie
 
Registered: Nov 2008
Location: Pennsylvania
Distribution: Fedora 19
Posts: 24

Original Poster
Rep: Reputation: 2
That's a great idea! I probably need a bit more skill with udev to implement it, though. I just made an edited copy of the 60 version and called it 61-... but the behavior of the cdrom did not change. Probably I need to set up 61 so it overrides instead of adds to 60. For reference, here's the code in 60-cdrom_id.rules:

Code:
# do not edit this file, it will be overwritten on update

ACTION=="remove", GOTO="cdrom_end"
SUBSYSTEM!="block", GOTO="cdrom_end"
KERNEL!="sr[0-9]*|xvd*", GOTO="cdrom_end"
ENV{DEVTYPE}!="disk", GOTO="cdrom_end"

# unconditionally tag device as CDROM
KERNEL=="sr[0-9]*", ENV{ID_CDROM}="1"

# media eject button pressed
ENV{DISK_EJECT_REQUEST}=="?*", RUN+="cdrom_id --eject-media $devnode", GOTO="cdrom_end"

# import device and media properties and lock tray to
# enable the receiving of media eject button events
IMPORT{program}="cdrom_id --lock-media $devnode"

KERNEL=="sr0", SYMLINK+="cdrom", OPTIONS+="link_priority=-100"

LABEL="cdrom_end"
and the 61 version is the same except the line starting with ENV{DISK_EJECT_REQUEST} is commented out. I suppose I need a way to remove the 60 version before implementing the 61. Am I going the right direction?
 
Old 03-12-2013, 06:35 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,490

Rep: Reputation: 611Reputation: 611Reputation: 611Reputation: 611Reputation: 611Reputation: 611
Put your modified 60-cdrom_id.rules file in /etc/udev/rules.d . That's where local overrides go. From `man 7 udev`:
Quote:
Rule files are required to have a unique name, duplicate file names are ignored.
Files in /etc/udev/rules.d/ have precedence over files with the same name in
/lib/udev/rules.d/. This can be used to ignore a default rules file if needed.

Last edited by rknichols; 03-13-2013 at 06:41 AM. Reason: typo
 
1 members found this post helpful.
Old 03-12-2013, 06:46 PM   #5
farnsy
LQ Newbie
 
Registered: Nov 2008
Location: Pennsylvania
Distribution: Fedora 19
Posts: 24

Original Poster
Rep: Reputation: 2
That worked perfectly. Thanks rknichols! I'll be sure to read the man page more carefully next time.

So the solution is to put a rule of the exact same name in /etc/udev/rules.d.
 
Old 03-12-2013, 07:11 PM   #6
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,397

Rep: Reputation: 1114Reputation: 1114Reputation: 1114Reputation: 1114Reputation: 1114Reputation: 1114Reputation: 1114Reputation: 1114Reputation: 1114
Or, you could re-program your toddler . . .
 
Old 03-12-2013, 11:52 PM   #7
farnsy
LQ Newbie
 
Registered: Nov 2008
Location: Pennsylvania
Distribution: Fedora 19
Posts: 24

Original Poster
Rep: Reputation: 2
Haha, working on it.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Write udev rule to change harddisk timeout EricTRA Linux - Virtualization and Cloud 9 06-11-2010 06:55 AM
First UDEV Rule, Not quite there ... orbit Slackware 7 02-22-2009 10:08 PM
udev rule: need help DPenguin Linux - Hardware 0 08-04-2008 07:29 PM
Udev Rule Help Please Toods Slackware 1 11-23-2007 08:55 AM
need help with udev rule hussam Linux - Software 2 12-05-2006 03:30 AM


All times are GMT -5. The time now is 05:50 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