LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-15-2008, 03:16 AM   #1
girish_hilage
Member
 
Registered: Oct 2003
Posts: 78

Rep: Reputation: 15
CD drive remains mounted


Hi,
I have 2 questions related to CD drive.

1.On my machine with kernel (2.6.16.40) I am using a CD drive.
The problem is that :
When I eject the CD I am currently using (it does not get unmounted when I see it using 'mount' command) and insert some other CD and start using it, still I can see and use the data on the previous CD.

I used the kernel variable "dev.cdrom.lock = 0" to be able to eject the CD when I press the eject button on an external CD drive. By default "dev.cdrom.lock = 1" because of which I was not able to eject CD.

So, does anybody know the reason why I am seeing the data from old CD?
I do not want to run 'automount' on my system.

2. How do I know in my application that a particular CD drive is being used for last how many minutes?

Regards,
Girish

Last edited by girish_hilage; 09-15-2008 at 08:41 AM.
 
Old 09-15-2008, 03:45 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
"it does not get unmounted..."

If you don't unmount it, how does the computer know that the disk isn't still there? You're forcing it to eject without unmounting, and that's a bad thing, since it's the umount command that tells the system the device is no longer present. You really need to always run it before removing a device, especially removable usb drives and such, but also optical disks.

One option might be to use ivman. You should be able to set it to automatically run umount when hal reports that the cd is no longer present. I don't really know if it's a good idea to run umount after the mounted device disappears though. See this article for more details.

Last edited by David the H.; 09-15-2008 at 03:46 AM.
 
Old 09-15-2008, 10:49 AM   #3
girish_hilage
Member
 
Registered: Oct 2003
Posts: 78

Original Poster
Rep: Reputation: 15
Thanks for the reply.
Can I use udev rule to unmount the CD drive once 'eject' button is pressed?
 
Old 09-15-2008, 12:37 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by girish_hilage View Post
Thanks for the reply.
Can I use udev rule to unmount the CD drive once 'eject' button is pressed?
If you have an application that's using the drive, it'll remain locked until it's unmounted. It's a bad idea to mess with the udev rules for something like this, they exist for a reason.

You say you can access the files, but what you can probably do is see the directory listing. If you try to open or run one of those files, it'll give you an error message.

The best thing you can do is to unmount the drive, before ejecting the CD. If you try to unmount it, and it gives a message about the device being busy, you're either still in that directory, or a program you have is still accessing that drive. Change directories, or stop the program.
 
Old 09-18-2008, 08:36 AM   #5
girish_hilage
Member
 
Registered: Oct 2003
Posts: 78

Original Poster
Rep: Reputation: 15
Hi,

I have few other queries as follows :

I tried "udevmonitor --kernel --udev" :

1. In case 'hald' is running it shows following events :
add (when I plugin the CD ROM)
remove (when I plugout the CD ROM)
umount (when I eject the CD ROM)
mount (when I insert the CD ROM)

2. In case 'hald' is stopped I can only see add,remove events but not the umount,mount events.

So, I have following queries :
1. why I can not see umount and mount in the 2nd case
2. how 'hald' and 'udev' communicate
3. if I use 'hald' then is 'automount' not required
4. how 'automount' and 'udev' communicate

Regards,
Girish
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't keep CD drive mounted Allen Higgins Slackware - Installation 2 02-12-2008 03:21 PM
drive mounted noobtesting Mandriva 3 10-05-2004 07:51 PM
shortcut to mounted drive woja Linux - Newbie 3 11-06-2003 02:14 AM
Trouble with mounted drive. LizardMan Linux - Hardware 3 06-19-2003 05:40 PM
Mounted drive read-only! MultiMike Linux - Newbie 8 06-09-2003 04:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:13 AM.

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
Open Source Consulting | Domain Registration