Linux - GeneralThis 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
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.
I know that you can use udev to automount removable devices like USB disk drives when they are inserted, since you can attach actions to the creation of each device. This facility relies upon the kernel reporting a "hotplug" event to udev when the drive is connected to a USB port. My question is whether a similar report is issued when I put a CD into my computer, or a floppy disk. See, the devices for a CD or floppy drive always exist even if the drive is empty, so udev can't help here, but if a hotplug event is issued I could write my own script to perform the action.
I micromanage my own system and I don't use the hotplug scripts, so don't suggest that as a solution. I just want to know if it's possible.
It must be - in ubuntu, I insert the CD and an icon appears on the desktop.
The drive can tell the kernel when media is inserted (when it whirres away after insertion like).
This doesn't mean that the kernel does what I want. Ubuntu could be using Supermount, which handles this situation differently. It's an obsolete kernel patch which is kept alive by others and I'd rather not use it.
Quote:
Originally Posted by Simon Bridge
Have you tried taking a diff from the dmesg output before and after a cdrom is inserted?
Ubuntu could be using Supermount, which handles this situation differently.
It's not. It's using HAL with a desktop volume manager, which is considered the right way to do things these days.
To answer your question, no you can't use a udev script to detect a CD insert. No device creation means no udev event.
However, with the advent of HAL, you don't really want to be using udev scripts anyway. HAL presents a unified interface for that can detect insertion and removal of CDs, USB flash drives, and other types of hardware. It's a lot more flexible than udev scripts and you can customize the actions taken when a device is inserted without having root access.
On the down side, if your distribution doesn't support it out of the box, it could be a big pain to get working.
It's not. It's using HAL with a desktop volume manager, which is considered the right way to do things these days.
To answer your question, no you can't use a udev script to detect a CD insert. No device creation means no udev event.
However, with the advent of HAL, you don't really want to be using udev scripts anyway. HAL presents a unified interface for that can detect insertion and removal of CDs, USB flash drives, and other types of hardware. It's a lot more flexible than udev scripts and you can customize the actions taken when a device is inserted without having root access.
On the down side, if your distribution doesn't support it out of the box, it could be a big pain to get working.
My question wasn't exactly whether I could use a udev script to do this; actually, it was whether I could bypass udev to do this since obviously udev won't work. However, it wasn't very well phrased, and it doesn't matter.
Thanks for mentioning HAL; this seems to be what I am looking for. I will have a look at it. My "distribution" started as Linux from Scratch and has since departed even from that, so one could say it supports everything, all of it with great difficulty.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.