[SOLVED] udev not detecting change in media for optical drive
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
udev not detecting change in media for optical drive
Alright, here is my situation. I have a udev rule setup to run a script every time an audio cd is inserted. This udev rule was working perfectly for 2 days. I restarted the system and now the script will not run. The udev rule is below. Please help me troubleshoot this issue as this was my first udev endeavor.
There is an exception, when I access the drive in anyway the script kicks off. For example, if I run `dd if=/dev/sr1 of=/dev/null bs=512 count=1` the script will execute immediately. But the purpose of this is so I don't have to execute a command, otherwise I would just launch the script manually.
Suggestions?
---Update---
I am marking this problem as solved. The relevant solution is to open a handle on the drive (basically what dd or another program was doing). Below is a link to a user post tha fixed the issue for me. It is some c code that opens\closes a handle on the drive every second. This causes the drive to update with udev as expected.
I have set up a few udev rules, but really know very little. Two thoughts come to mind. Perhaps everything is not ready when udev executes the rule so you need to execute later. The other idea is that you might make something happen elsewhere, like with xinit or profile.d.
udevadm monitor does not show a change on the device until it is accessed. Once it is accessed everything works as expected. Again this is a new issue since a reboot.
I don't know how to proceed if the udev event doesn't even register until it is accessed. I need a direction to continue troublshooting.
As a note, I have several rules for usb devices and such that all work great, it is only the optical drive that does not work currently. I have swapped the drives to no avail.
If this is the first time you rebooted after making the rule, your drive was already accessed. Udev may be ignoring the rule on startup because of the way it is written. If you add another rule before this one that only sets up the drive, I think everything would work.
There is no disc in the drive on startup. Appending the first string also does not help, but again the udev is not even registering a change on the device until it is accessed. Then it works as designed, and was working previously.
I am out of my natural habitat here, but I will make one more suggestion because I would be as frustrated as you are given the same circumstances. If it were mine, I would reboot. After the machine stabilizes, run "lsmod" to see which modules loaded. Then, access the drive, but don't insert the CD. Run "lsmod" again to see what new module may have loaded. If there is a change, you may have to use one of your startup scripts to load the module at the beginning.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.