Most mount
commands support the user option. If you
make an entry such as the following in /etc/fstab:
/dev/sbpcd /mnt/cdrom iso9660 user,noauto,ro
then an ordinary user will be allowed to mount and unmount the drive using these commands:
% mount /mnt/cdrom
% umount /mnt/cdrom
By default the disc will be mounted with some options that help enforce security (e.g. programs cannot executed, device files are ignored). If this is too restrictive you can use additional options (e.g. the "exec" option will enable execution or programs). See the mount(8) man page for details.
Another method is to get the usermount
package which allows
non-root users to mount and unmount removable devices such as floppies
and CD-ROMs, but restricts access to other devices (such as hard disk
partitions). It is available on major archive sites.
The archive site ftp.cdrom.com
has the source file
mount.c
which allows mounting an unmounting of CD-ROMs (only)
by normal users. It runs as a setuid executable.
The disc cannot be unmounted if any processes are accessing the drive,
including having their default directory set to the mounted
filesystem. If you cannot identify the processes using the disc, you
can use the fuser
command, as shown in the following example.
% umount /cdrom
umount: /dev/hdd: device is busy
% fuser -v /cdrom
USER PID ACCESS COMMAND
/mnt/cdrom tranter 133 ..c.. bash
On some systems you may need to be root when running the
fuser
command in order to see the processes of other users.
You need to add an entry to the /etc/exports file. Users on
other machines will then be able to mount the device. See the
exports(5)
man page for details.
When initially installing Linux the most common method is to use a boot floppy. Some distributions allow booting a Linux kernel on CD directly from DOS.
With the right CD-ROM, ROM BIOS, and ATAPI CD-ROM drive it is possible
to boot directly from CD. The latest version of mkisofs
supports creating such disks using the El Torito standard for bootable
CDs.
Heiko Eissfeldt (
heiko@colossus.escape.de) and Olaf Kindel have written a
utility that reads audio data and saves it as .wav
format
sound files. The package is called cdda2wav.tar.gz
and can be
found on metalab.unc.edu
.
Another utility to extract digital audio is cdparanoia
available from
http://www.mit.edu/afs/sipb/user/xiphmont/cdparanoia.
Because CD-ROM drives are changing very quickly, it is difficult to
list which models support reading digital data. You best
bet is to get the latest cdda2wav
or cdparanoia
package and read the documentation.
For more information on this subject, see the web site http://www.tardis.ed.ac.uk/~psyche/cdda/ and the alt.cd-rom FAQ listed in the references section.
On ISO-9660 formatted discs without the Rock Ridge Extensions, you
need to add the -noleaf
option to the find
command.
See the find(1) man page for details.
(In my experience virtually all recent Linux CDs use the Rock Ridge extensions, so this problem should occur very rarely.)
The X-CD-Roast package for Linux is a graphical front-end for using CD writers. The package can be found at metalab.unc.edu in /pub/Linux/utils/disk-management/xcdroast-0.95.tar.gz
Also see the Linux CD-Writing HOWTO document, found at ftp://metalab.unc.edu/pub/Linux/docs/HOWTO/CD-Writing-HOWTO or http://metalab.unc.edu/LDP/HOWTO/CD-Writing-HOWTO.html.
CD-ROM is a read-only media. With some early kernels you could mount a CD-ROM for read/write; attempts to write data to the CD would simple be ignored. As of kernel version 1.1.33 this was corrected so that CD-ROMs must be mounted read only (e.g. using the -r option to mount).
The sbpcd driver supports automatically ejecting the CD when it is unmounted. In some older kernel versions this was the default behaviour. If you shut down the system, a mounted CD will be unmounted, causing it to eject.
This feature is for convenience when changing discs. If the tray is open when you mount or read a CD, it will also automatically be closed.
I found that this caused problems with a few programs (e.g. cdplay and workbone). As of the 1.1.60 kernel you can control this feature under software control. A sample program is included in the sbpcd documentation file (or use the eject program). You can also control the default behaviour by editing the kernel source file sbpcd.h.
The "special" CD is likely an XA disc (like all Photo CDs or "one-offs" created using CD-R drives). Most of the Linux kernel CD-ROM drivers do not support XA discs, although you may be able to find a patch to add support on one of the archive sites.
The sbpcd driver does support XA. If you are using this driver you can determine if the disc is XA using the following procedure: go into the file sbpcd.c and enable the display of the "Table of Contents" (DBG_TOC). Build and install the new kernel and boot from it. During each mount the TOC info will be written (either to the console or to a log file). If the first displayed value in the TOC header line is "20", then it is an XA disc. That byte is "00" with normal disks. If the TOC display shows different tracks, that is also a sign that it is an XA disc.
(thanks to Eberhard Moenkeberg for the above information)
Other possibilities for unreadable CDs are:
Several users have reported success with SCSI multi-disc CD-ROM changers. You probably need to enable the "Probe all LUNs on each SCSI device" kernel configuration option (this is not necessary if your CD changer is already known to the SCSI-driver. Have a look at /usr/src/linux/drivers/scsi.c).
At least one user also had to increase a SCSI timeout value in the kernel driver. A symptom of this is an error message like "wrong fs type, bad option, bad superblock on /dev/sr5, or too many mounted file systems" when trying to mount a CD for the first time, but a second mount immediately afterwards succeeds. To increase the timeout increase the value of IOCTL_TIMEOUT at the beginning of /usr/src/linux/drivers/scsi/sr_ioctl.c and recompile the kernel. A value of 10000 instead of the default 3000 is reported to work with a NEC Multispin 4Xc.
It might be necessary to create additional block special files, so
that all LUNs can be accessed. A device file is needed for every
LUN. So for a 7 disc changer /dev/sr0
to /dev/sr6
are needed (more if you have additional SCSI CD-ROM drives). To create
the block special file execute mknod /dev/sr? b 11 ?
as root
with ? being the required number.
The Nakamichi MBR-7 7 disc changer, NEC Multispin 4Xc and Pioneer 12 disc changer have been reported to work.
EIDE/ATAPI multi-disc changers are also available. The kernel has
support for some drives using the CDROM_SELECT_DISC ioctl
function. The IDE-CD kernel driver documentation file includes source
code for a program to select changer slots, or you can use various
utilities such as the eject
program described earlier.
Some CDs have root directory file permissions that only allow user
root
to read them. This is an error on the part of the CD-ROM
vendor and is a real inconvenience. A more common occurrence is for
certain files or directories not to be world readable. Some people
have patched their kernels to work around the problem.
Also see the related question on hidden files later in this document.
What does it mean when I get a kernel message from the IDE CD-ROM driver like "hdxx: code: xx key: x asc: xx ascq: x"?
This is an status/error message from the IDE CD-ROM drive. By default the IDECD driver prints out the raw information instead of wasting kernel space with error messages. You can change the default to display the actual error messages by going into /usr/src/linux/drivers/block/ide-cd.c, changing the value of VERBOSE_IDE_CD_ERRORS to 1, and recompiling the kernel.
Here's one way. This command measures how long is takes to read 1500K of data from CD:
% time -p dd if=/dev/cdrom of=/dev/null bs=1k count=1500
1500+0 records in
1500+0 records out
real 5.24
user 0.03
sys 5.07
The transfer rate of single speed drives is 150 kilobytes per second, which should take about 10 seconds. At double speed it would take five seconds, quad speed would take 2.5, etc.
The "real" time above is probably the best number to look at -- in this case it indicates a double speed drive. You can increase the amount of data transferred to get a more accurate value (in case you were wondering, the data does not get cached). You should probably run the command a few times and take the average.
I've also written a small C program that measures and reports CD-ROM data transfer rate; I can send it to you on request.
The usual symptom is that the boot disk used to initially install Linux recognized your CD-ROM drive, but after Linux was installed on the hard drive or floppy and rebooted it no longer recognizes the CD-ROM.
The most common reason for this problem is that with some Linux distributions the kernel that is installed on your hard drive (or floppy) is not necessarily the same one that was on your boot disk. You selected a boot disk that matched your CD-ROM hardware, while the kernel you installed is a "generic" kernel that is lacking CD-ROM support. You can verify this by following the troubleshooting guidelines discussed previously in this document (e.g. start by checking /proc/devices).
The solution is to recompile the kernel, ensuring that the drivers for your CD-ROM drive and any others that are needed (e.g. SCSI controller, ISO-9660 file system) are included. See the Kernel HOWTO if you don't know how to do this.
If you passed any command line options to the boot disk (e.g. "hdc=cdrom") you need to add these to your boot program configuration file (typically /etc/lilo.conf).
Some CDs have files with the "hidden" bit set on them. Normally these files are not visible. If you mount the CD with the "unhide" option then the files should be accessible (this doesn't seem to be documented anywhere).
If you want to write your own application, such as an audio CD player program, you will need to understand the application programming interface (API) provided by Linux.
Originally the CD-ROM kernel drivers used their own ioctl() functions to support features specific to each drive. Header files such as /usr/include/linux/sbpcd.h describe these. Because many of the drivers were based on other drivers, the interfaces, while not identical, have a lot in common.
More recently there has been an initiative headed by David van Leeuwen ( david@tm.tno.nl) to standardize the API for CD-ROM drives, putting common code in one place and ensuring that all drivers exhibit the same behaviour. This is documented in the file /usr/src/linux/Documentation/cdrom/cdrom-standard.tex. Several kernel drivers support this. As of the 2.0 kernel all CD-ROM drivers conform to this API.
My book, Linux Multimedia Guide, goes into quite a bit of detail on how to program CD-ROM drives, especially for audio functions. See the end of the References section.
If you have a CD-ROM which has long filenames under Windows but not under Linux, it may be formatted using Microsoft's proprietary Joliet filesystem. See the next question for a solution.
Microsoft has created an extension to the ISO CD-ROM format called Joliet. It allows for long filenames encoded using the 16-bit UNICODE format.
Starting with version 2.0.34 the Linux kernel has support for the Microsoft Joliet file system extensions. You need to enable support for it in the kernel.
If you want to display filenames with native language characters from Joliet CD-ROMs correctly on the screen, you need to enable support in the kernel for the appropriate NLS ISO8859 character sets.
Some audio CDs are "enhanced" with additional data. Typically you will find that these CDs have the usual audio CD tracks as well as a data track which can be mounted as an ISO-9660 file system.
An enhanced CD I examined had Microsoft Windows and Apple Macintosh
applications on it (which won't run directly under Linux of course,
although I had partial success running the Windows application under
the WINE Windows emulator). There were some GIF images which could be
viewed using a standard viewer such as xv
and some animations
in Apple QuickTime format which could be viewed using the
xanim
program. It was a multisession disk which some very old
CD-ROM drives do not support reading. On the disc was a
readme.txt
file containing an Enhanced CD FAQ.
SCSI and ATAPI compliant DVD-ROM drives should work under Linux for reading discs formatted with an ISO-9660 file system. In other words they will work as a (possibly large) CD-ROM drive.
Many DVD-ROM discs use the UDF file system. At the time of writing this was still in development. Kernel patches were available from http://trylinux.com/projects/udf/.
However, I am not aware of any support for playing MPEG-2 encoded DVD videos either in software or in conjunction with DVD decoder hardware. Apparently the standard document for the encoding format can only be obtained at a high cost and under a non-disclosure agreement. Another issue is that MPEG decoding typically uses proprietary hardware for which the vendor may not be willing to release programming information. These factors may preclude any freely available DVD video software being developed for Linux.
SCSI and ATAPI compliant CD-RW drives should work under Linux for discs formatted with an ISO-9660 file system. This includes the ability to write to the disc.
Many CD-RW discs use the UDF file system. At the time of writing this was still in development. Kernel patches were available from http://trylinux.com/projects/udf/.