LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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.

Notices


Reply
  Search this Thread
Old 02-15-2011, 11:47 AM   #1
Johncc330
Member
 
Registered: Mar 2007
Posts: 101

Rep: Reputation: 19
cd/dvd mount problem - where to start?


Hello all.

A couple of years ago I wrote a small utility (in C) to read CDs and DVDs, and index their contents. It just mounts the disk, reads the filenames, and ejects the disk.

With a recent update of the OS, I increasingly experience problems. The program irregularly couldn't mount the disk, or ejected it too soon. According to what I read in several threads, the problem is probably
with udev, which seems to automount (and then unmount) the drive.

The problem also exists if just running 'mount /mnt/dvd' if the disk has just been inserted. If I wait a considerable time, the mount command does work. I suspect one of the problems is that udev only assigns device names after the disk has been detected?

Finally the Question:

What is the correct way to mount/unmount a (removable) disk by software?

- Do I have to retry till mount works correctly?
- Do I need to talk to udev/hal directly?
- any other solution/pointer/suggestion?

I'm running Slackware64 13.1, kernel is updated to 2.6.36.1.

John
 
Old 02-15-2011, 01:16 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Quote:
I suspect one of the problems is that udev only assigns device names after the disk has been detected?
In the distros I've used which use udev, that's the default behavior. You may, if you choose to do so, write a custom udev rule to change that behavior. Do some research on writing udev rules via www.google.com/linux.

Quote:
What is the correct way to mount/unmount a (removable) disk by software?

- Do I have to retry till mount works correctly?
- Do I need to talk to udev/hal directly?
- any other solution/pointer/suggestion?
First, you have to distinguish between data disk and non-data disk (such as music, video, etc). You can mount a data disk to read files, but a non-data disk may be accessed as soon as udev creates the mount point in /media or /mnt (non-data disks are not mounted).

To eject a non-data disk, simply use the eject command from the command line.
To eject a data disk, you must first unmount the device or the mount point (umount /dev/hdc or umount /mnt/cdrom for example) before you can eject the disk.
 
Old 02-15-2011, 04:09 PM   #3
Johncc330
Member
 
Registered: Mar 2007
Posts: 101

Original Poster
Rep: Reputation: 19
Quote:
Quote:
I suspect one of the problems is that udev only assigns device names after the disk has been detected?

In the distros I've used which use udev, that's the default behavior. You may, if you choose to do so, write a custom udev rule to change that behavior. Do some research on writing udev rules via www.google.com/linux.
Hi bigrigdriver

There are strange things though: With a data disk in the drive:

- I (previously) set fstab to noauto, so it should not mount automatically.

- Still, udev does something with the drive this makes a too-fast mount command fail with 'no media'
till after about 30 seconds, when it mounts correctly.

- If I remove the mount point (/mnt/dvd), mount complains with 'No mount point' - it doesn't generate
a mount point automatically.

- Even though /media has /dvd, /dvd0, /dvd1 the dvd is not mounted under any of those either, and those
points are not generated dynamically either.

This describes the same problem:

https://lists.linux-foundation.org/pipermail/bugme-new/2008-June/018981.html



Quote:
First, you have to distinguish between data disk and non-data disk (such as music, video, etc). You can mount a data disk to read files, but a non-data disk may be accessed as soon as udev creates the mount point in /media or /mnt (non-data disks are not mounted).
Pure data...

Quote:
To eject a non-data disk, simply use the eject command from the command line.
To eject a data disk, you must first unmount the device or the mount point (umount /dev/hdc or umount /mnt/cdrom for example) before you can eject the disk.
I believe the eject command automatically issues an umount too, so that wouldn't be necessary.

John
 
  


Reply

Tags
cd, dvd, mount


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
mount as a device: mount dvd-iso file in /dev/dvd sadarax Linux - General 21 02-02-2011 11:59 PM
cd/dvd mount problem stunningman Linux - Newbie 5 01-27-2008 09:34 AM
DVD (auto)mount problem, gnome-mount, hal, Fedora C 5 lazarion Linux - Hardware 5 01-10-2007 04:45 AM
mount:not a directory. Suse dvd mount problem tzanis Linux - General 8 11-06-2005 11:30 AM
DVD Mount Problem Chryzmo Linux - Hardware 5 09-28-2004 09:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:33 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
Open Source Consulting | Domain Registration