Discussion:
What (probably in udev) controls symlink /dev/cdrom?
(too old to reply)
Robert Riches
2018-07-07 03:43:09 UTC
Permalink
What (probably in udev) controls symlink /dev/cdrom?

I have two optical drives on a Slackware 14.2 system. One is
used mostly for burning/writing. The other is used mostly for
reading. Symlink /dev/cdrom points at sr0, but I need it to
point at sr1 for this system.

As root, I can manually remove the symlink and create a new one
pointing to the correct-for-this-system device. However,
whenever I insert a disk or do some other operations on /dev/sr1,
something (probably udev) changes the symlink back to point at
sr0.

What rule or configuration file in udev determines which device
symlink /dev/cdrom points to?

Thanks,
--
Robert Riches
***@jacob21819.net
(Yes, that is one of my email addresses.)
Rich
2018-07-07 04:31:42 UTC
Permalink
Post by Robert Riches
What rule or configuration file in udev determines which device
symlink /dev/cdrom points to?
For reasonably modern Slackware versions, it is this file:

/etc/udev/rules.d/70-persistent-cd.rules
Henrik Carlqvist
2018-07-07 08:51:36 UTC
Permalink
Post by Rich
What rule or configuration file in udev determines which device symlink
/dev/cdrom points to?
/etc/udev/rules.d/70-persistent-cd.rules
My slackware 14.2 system does not have the file 70-persistent-cd.rules
and I can't find any startup file that creates it like
70-persistent-net.rules is created.

But I can see that the symlink /dev/cdrom is controlled by the script
/lib/udev/rules.d/60-cdrom_id.rules

That said, it is a better idea to write your own custom udev rules in
/etc/udev/rules.d than to mess around in the files in /lib/udev. The file
in /lib/udev might be a good starting point for your custom file which
should live in /etc/udev/rules.d and 70-persistent-cd.rules would not be
a bad name for that file if you don't want to add the rule to some other
existing file.

regards Henrik
Jerry Peters
2018-07-07 20:31:52 UTC
Permalink
Post by Henrik Carlqvist
Post by Rich
What rule or configuration file in udev determines which device symlink
/dev/cdrom points to?
/etc/udev/rules.d/70-persistent-cd.rules
My slackware 14.2 system does not have the file 70-persistent-cd.rules
and I can't find any startup file that creates it like
70-persistent-net.rules is created.
But I can see that the symlink /dev/cdrom is controlled by the script
/lib/udev/rules.d/60-cdrom_id.rules
That said, it is a better idea to write your own custom udev rules in
/etc/udev/rules.d than to mess around in the files in /lib/udev. The file
in /lib/udev might be a good starting point for your custom file which
should live in /etc/udev/rules.d and 70-persistent-cd.rules would not be
a bad name for that file if you don't want to add the rule to some other
existing file.
regards Henrik
A file in /etc/udev/rules.d overrides a the file with the same name in
/lib/udev/rules.d.

On 4.1, /lib/udev/rules.d/75-cd-aliases-generator.rules:
# these rules generate rules for the /dev/{cdrom,dvd,...} symlinks
Robert Riches
2018-07-08 03:35:46 UTC
Permalink
Post by Jerry Peters
Post by Henrik Carlqvist
Post by Rich
What rule or configuration file in udev determines which device symlink
/dev/cdrom points to?
/etc/udev/rules.d/70-persistent-cd.rules
My slackware 14.2 system does not have the file 70-persistent-cd.rules
and I can't find any startup file that creates it like
70-persistent-net.rules is created.
But I can see that the symlink /dev/cdrom is controlled by the script
/lib/udev/rules.d/60-cdrom_id.rules
That said, it is a better idea to write your own custom udev rules in
/etc/udev/rules.d than to mess around in the files in /lib/udev. The file
in /lib/udev might be a good starting point for your custom file which
should live in /etc/udev/rules.d and 70-persistent-cd.rules would not be
a bad name for that file if you don't want to add the rule to some other
existing file.
regards Henrik
A file in /etc/udev/rules.d overrides a the file with the same name in
/lib/udev/rules.d.
# these rules generate rules for the /dev/{cdrom,dvd,...} symlinks
Excellent! Thank you all very much for all the replies!

On my 14.2 system, I see /lib/udev/rules.d/60-cdrom_id.rules with
the line that creates the 'cdrom' symlink to 'sr0'. I'll plan to
copy that file to /etc/udev/rules.d and change that 'sr0' to
'sr1' with a comment to remind myself why I'm doing that.

Thanks!
--
Robert Riches
***@jacob21819.net
(Yes, that is one of my email addresses.)
Robert Riches
2018-07-14 23:42:43 UTC
Permalink
Post by Robert Riches
Post by Jerry Peters
Post by Henrik Carlqvist
Post by Rich
What rule or configuration file in udev determines which device symlink
/dev/cdrom points to?
/etc/udev/rules.d/70-persistent-cd.rules
My slackware 14.2 system does not have the file 70-persistent-cd.rules
and I can't find any startup file that creates it like
70-persistent-net.rules is created.
But I can see that the symlink /dev/cdrom is controlled by the script
/lib/udev/rules.d/60-cdrom_id.rules
That said, it is a better idea to write your own custom udev rules in
/etc/udev/rules.d than to mess around in the files in /lib/udev. The file
in /lib/udev might be a good starting point for your custom file which
should live in /etc/udev/rules.d and 70-persistent-cd.rules would not be
a bad name for that file if you don't want to add the rule to some other
existing file.
regards Henrik
A file in /etc/udev/rules.d overrides a the file with the same name in
/lib/udev/rules.d.
# these rules generate rules for the /dev/{cdrom,dvd,...} symlinks
Excellent! Thank you all very much for all the replies!
On my 14.2 system, I see /lib/udev/rules.d/60-cdrom_id.rules with
the line that creates the 'cdrom' symlink to 'sr0'. I'll plan to
copy that file to /etc/udev/rules.d and change that 'sr0' to
'sr1' with a comment to remind myself why I'm doing that.
Thanks!
After finally getting a few minutes to experiment with this, I
found a result that works well enough for me but is not entirely
consistent with how it sounds like it should work.

When I created a /etc/udev/rules.d/60-cdrom_id.rules file with
'sr1' rather than 'sr0' as in /lib/..., the next qualifying
operation with that device caused the /dev/cdrom symlink to go
away and stay gone. After trying a few variations, I settled on
modifying the /lib/... file to have 'sr1' rather than the
original 'sr0'. After settling on that final file content, I did
a 'udevadm control --reload' to try to cause udevd to reload all
the files. Even after that, the symlink stayed gone. That's not
how it sounded like it is supposed to work. Perhaps there might
be a conflict somewhere that my simple greps did not find.

For my present situation, that works well enough, and I
appreciate the pointers to the rules files. I manually created
the symlink. As part of my RCS'ed system administration
directory, I check the contents of the files and of the symlinks,
so if a package update changes things back, I'll know about it
immediately and can take corrective action.

Thanks again!
--
Robert Riches
***@jacob21819.net
(Yes, that is one of my email addresses.)
Loading...