LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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



Reply
 
Search this Thread
Old 08-05-2006, 11:10 PM   #1
ryanreich
LQ Newbie
 
Registered: Apr 2005
Posts: 6

Rep: Reputation: 0
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
 
Old 08-06-2006, 04:49 AM   #2
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
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?
 
Old 08-06-2006, 09:18 AM   #3
ryanreich
LQ Newbie
 
Registered: Apr 2005
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Simon Bridge
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?
I don't get anything...
 
Old 08-06-2006, 10:45 AM   #4
AdaHacker
Member
 
Registered: Oct 2001
Location: Brockport, NY
Distribution: Kubuntu
Posts: 384

Rep: Reputation: 31
Quote:
Originally Posted by ryanreich
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.
 
Old 08-06-2006, 10:49 AM   #5
ryanreich
LQ Newbie
 
Registered: Apr 2005
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by AdaHacker
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.

Thanks,
Ryan
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Does dpkg work with removable devices? jolphil Debian 13 03-23-2005 04:14 PM
Debian and removable devices. Sslaxx Debian 2 02-09-2005 02:24 PM
how to stop mandrake/kde from automounting nonexistent removable devices at startup? pdmackenzie Mandriva 3 11-08-2004 10:53 AM
A simple question about hotplugging usb devices czechknight93 Linux - Hardware 2 04-07-2004 02:28 AM
Automounting a removable drive rhraz Linux - Newbie 1 03-11-2004 01:02 PM


All times are GMT -5. The time now is 08:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration