[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.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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.
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.
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.