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.
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:
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.
I believe the eject command automatically issues an umount too, so that wouldn't be necessary.