Hotplugging and automounting removable devices?
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. Thanks, Ryan |
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). Have you tried taking a diff from the dmesg output before and after a cdrom is inserted? |
Quote:
Quote:
|
Quote:
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. |
Quote:
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. Thanks, Ryan |
All times are GMT -5. The time now is 08:03 PM. |