The CD-ROM drive has changed from an expensive peripheral to almost a mandatory drive for most PC users. As prices of CD-ROM drives have dropped and the amount of software distributed by CD-ROM has increased, the CD-ROM drive has become a necessary system component, especially for users of large software packages like Linux. Because of its device driver architecture, Linux supports CD-ROM drives easily. This chapter looks at the support built into Linux for a CD-ROM and gives general instructions for installing and configuring a CD-ROM drive.
A CD-ROM holds a large amount of material (approximately 650M) in a convenient size. CD-ROMs are non-volatilethey don't lose data when exposed to magnetic fields, and they are difficult to damage. As with any new technology, though, CD-ROMs took a while to become a common item, and several different, competing formats were developed while the technology was evolving. Most formats were incompatible with each other or were specific to a type of hardware or CD-ROM software driver. The adoption of a single CD-ROM standard format has helped spread CD-ROM usage throughout the UNIX and Linux communities.
Several different types of CD-ROM drives are available. Choosing the right drive for your Linux system is often a matter of balancing features against costs. Although it's tempting to purchase the state-of-the-art drive, you may be wasting your money if you do so.
You can buy CD-ROM drives in both internal and external models. You must attach an internal CD-ROM drive to a drive bay and a controller card (which you may already have) within your computer. An internal CD-ROM drive draws its power from a connector to the PC power supply. Before you purchase an internal CD-ROM drive, make sure you have a drive bay available for it and a spare power connector.
Don't assume that drive bays are available inside your machine for a CD-ROM drive just because you see featureless plastic panels on the front. There may be hard drives mounted behind these panels. Take off the cover of your machine and check for a full-width (5.25-inch wide) slot that can hold your CD-ROM drive. If you don't have any power connectors available inside the machine, you can attach a Y-connector to expand a single connector to two.
Before you add an internal CD-ROM drive, check that your power supply has adequate reserve to power it and all the other devices within your machine. Newer machines usually have enough power, but some older PC units are underpowered and have power supplies capable of powering only floppy and hard drives. If you have any doubts, check the ratings on the power supply, or consult your dealer. CD-ROM drives do not require a lot of power, but a surge from the CD-ROM drive may adversely affect other devices in your system.
External CD-ROM drives are easier to connect, in most cases, because they have an external power supply and attach to the outside edge of a board in one of your machine's expansion slots. Some interface types (such as IDE) do not support external drives easily as the IDE controller card has no external connector. Check the interface and cabling before you purchase an external CD-ROM drive. External CD-ROM drives tend to be more expensive then internal drives because of the additional case and power supply.
Most CD-ROM drives hold a single CD, either in a slide-out tray like many audio CD players or in a CD caddy, which is a holder that you open and into which you insert the CD. You then place the caddy inside the CD-ROM drive. Caddy and caddyless systems work equally well, with some users preferring no caddy and others liking the caddies. Most current high-end CD-ROM drives use caddies.
CD-ROM changers are also available. These CD-ROM drives hold four or more CDs at the same time. Most CD-ROM changers use a cartridge that holds six CDs, a system similar to the one used in audio CD changers. A few changers hold 18 or more CDs. These changers allow you to load up the unit with your favorite discs, and then select the one you want using software. Only one disk is loaded in the CD-ROM drive mechanism at a time, with the others just held internally for convenience. In other words, you can't access two CDs in a multi-CD changer at the same time because there is only one read mechansim into which the stored CD-ROMs are shuffled. Not all operating systems support changers because the commands to alter and remount CDs can be cumbersome to implement, especially in a real-time operating system like Linux. Linux handles some CD-ROM changers that behave as a regular CD-ROM drive, although you may have to change CD-ROM discs manually by unmounting a currently loaded disc, changing to another disc, and then remounting. Newer drivers are beginning to appear for popular changers that perform this process automatically, although none are supplied with Linux distributions at this time.
CDs can be formatted in several different ways, depending on the type of machine the information is designed for. A CD-ROM designed for a PC, for example, is not necessarily readable on a Macintosh. For this reason, a standardized format was developed for CD-ROMs called ISO 9660. The ISO 9660 format was called the High Sierra format before being adopted by ISO, and both terms are in common usage still.
The ISO 9660 format dictates filenames in a strict DOS format(eight character filename and three character filetype). This format is fine for DOS-based machines and operating systems, but it is very restrictive for UNIX, which allows long filenames and doesn't force a convention for filetyping. To get around the DOS format limitations, a system called the Rock Ridge Extensions was developed. The Rock Ridge Extensions allow unused fields in the ISO 9660 data format to be used to provide much longer filenames, as well as UNIX-based information such as links, permissions, and so on. The Rock Ridge Extensions are in wide use for most UNIX and Linux ISO 9660 disks, although all these disks can be used in the basic ISO 9660 format too.
A few years ago, Kodak developed a graphics file storage format called PhotoCD. PhotoCD allows photographic and other visual images to be stored on a CD-ROM as digital data. The CD-ROM drive can then quickly recall this digital data and assemble it into the image it represents. Linux supports PhotoCD formats through utilities that allow PhotoCD files to be displayed.
Most CD-ROM device drivers also enable the user to play standard music CD discs by providing an on-screen control that steps through tracks and handles pauses, fast forwards, and so on. Audio-only CD-ROMs have no picture information and can't be decoded by Linux, other than as a sound source. Linux includes utilities that support the playing of audio-only CD discs, such as Workman (available in both character and X versions).
CD-ROM drives are available in a number of different speeds, which dictate the transfer rate of data between the CD-ROM and the computer. The first generation of drives was called single speed and could transfer information at approximately 150K per second. Double speed CD-ROM drives, as the name suggests, effectively double the transfer rate to over 300K per second. Quad speed and six speed drives increase the transfer rates even more. Of course, as the speed increases, so does the price.
Pure CD-ROM speed is not as important as your system's capability to receive the information. If your CD-ROM drive is capable of reading data at 750K per second, for example, but your interface card to the CD-ROM drive is capable of handling only 300K per second, the extra speed is useless. Also, if your device driver or application talking to the CD-ROM can't keep up, extra speed is again wasted.
The speed issue depends to a large degree on the type of interface you are using between the CD-ROM player and your system. The best interface is SCSI (see Chapter 7, "SCSI Devices," for more information) because it supports the highest transfer speeds and widest variety of supported CD-ROM players. Linux using a SCSI interface can provide full support for the fast CD-ROM drives, and a quad speed drive is noticeably faster at retrieving a large file than a double speed, for example. Because SCSI costs considerably more than other interfaces, most Linux systems use either an IDE (Integrated Drive Electronics) or sound card-based (proprietary) CD-ROM connector. These interfaces have a limited throughput and the newer six speed CD-ROM drives can be much faster than the interface can handle in a heavily loaded system. For these interfaces, a quad speed or even a double speed CD-ROM drive is usually sufficient.
SCSI is a standard bus interface that connects all peripherals in a long chain. You can plug a CD-ROM drive into the chain at any location. Each SCSI device has all the device electronics and basic communications drivers built into the drive's electronics (which accounts for the drive's higher price). These built-in components mean that any SCSI CD-ROM drive can be plugged into a SCSI system. As long as it's SCSI, it will work with Linux. (Linux also requires the CD-ROM drive to have block sizes of 512 or 2048 bytes, but most CD-ROM drives support these sizes. A few proprietary CD-ROM drives used by workstation and minicomputer manufacturers do not conform to these block sizes, but it is unlikely you could purchase such a CD-ROM drive easily.)
SCSI also allows more than one CD-ROM drive on a system at a time. You can easily have two, three, four, or more CD-ROM drives connected and available simultaneously. In contrast, a CD-ROM changer houses several CD-ROM discs at a time in cartridges, but only one CD disc is loaded and active at a time.
Some available SCSI-based CD-ROM interface cards are not fully SCSI interfaces, but a reduced set designed to support the CD-ROM drive only. These cards work with Linux as they conform to the SCSI standards, but you cannot add hard drives and other SCSI devices to them. Check the CD-ROM drive's documentation to determine whether the interface card supplied with the CD-ROM (if there is one) offers full or partial support.
True IDE CD-ROM drives plug into the IDE controller card that handles the hard drive in most PC systems. Older IDE systems can only handle two devices, which means that you can only have one hard drive and your CD-ROM drive. Newer EIDE (Extended IDE) cards can handle four devices. The IDE CD-ROM drives use a modified version of the hard disk standard called ATAPI. IDE CD-ROM drives are still fairly new, and they are generally inexpensive (as the IDE interface card has all the electronics, not the drive). A few IDE CD-ROM drivers are compatible with Linux, and more are being added as CD-ROM drives are released.
Don't confuse IDE CD-ROM drives with proprietary CD-ROM drives. Proprietary CD-ROM drives use the PC Bus, as does IDE, and can be misleadingly labeled. Check the descriptions carefully. IDE CD-ROM drives attach to an IDE controller card; they never attach to a sound card.
Proprietary CD-ROM drives are another problem, as the many different models of CD-ROM drive all have different communication methods. Proprietary drives are usually packaged either as a stand-alone CD-ROM or combined with a sound card as a multimedia system. In all these proprietary systems, the CD-ROM plugs into a special connector on the interface card. Most proprietary CD-ROM drives are internal models. These proprietary CD-ROM drives are not interchangeable and generally require different device drivers for each model. Some proprietary CD-ROM interface cards allow up to four CD-ROM drives to be connected to one controller and up to four controllers to be present at a time. The newer Matsushita/Kotobuki drives all support this expansion, for example.
The most commonly used proprietary CD-ROM drive is one manufactured by Matsushita and partners, which is sold under many trade names (including Creative Labs, Panasonic, and others). Linux also supports several Sony CD-ROM drives and some Philips drives. A list of all supported CD-ROM drives is supplied with the Linux distribution set and is updated with each new release. Check the list supplied with your version of Linux and the manufacturer of the drive you're considering before you purchase a CD-ROM drive, if possible. Note that many companies relabel these drives to their own brand names, so it may be a little difficult to determine who manufactured the drive and its model number just by looking at the box. If you can't tell who made the CD-ROM drive, and it's not a major brand name (such as Creative Labs), postpone purchasing the unit until you can get more information about it. Most boxes have a telephone number for the vendor, so copy it down and give the vendor a call. (Beware of salespeople who give you the "of course it will work" line; most of them have no idea!) If your distribution software does not have support for your proprietary CD-ROM, you can check the FTP and BBS sites for new drivers. The primary proprietary models are supported, though.
Another differentiating factor with CD-ROM drives is the amount of RAM provided on the drive unit. This difference is common among SCSI drives. Most drives have 256K RAM, and others sport 1M or more. Plextor drives (such as the Plextor 4Plex and 6Plex) are usually available with 1M and are some of the fastest CD-ROM drives available for Linux and DOS/Windows. In theory, the more RAM there is on board, the more buffering and caching the drive can perform. Because Linux has a cache system of its own, the on-board RAM is generally not as important a factor as access speed, although more RAM does provide a small increase in speed.
A slight variation on the CD-ROM drive is the newer CD-R (Compact Disk - Recordable) drive, which is essentially a CD-ROM drive that can write to a CD. CD discs are only capable of being written to once, so these devices are usually limited to special applications. Most CD-R drives are designed for DOS/Windows, although a few have generic UNIX drivers designed for high-end multimedia workstations.
You can add a CD-R drive to a Linux system, although few drivers are available for actually writing data to the CD-R. If you have a CD-R drive that you want to use with Linux, you can install it as a CD-ROM drive for read-only purposes. If you want to write data to the CD, you will have to find an application that is compatible with Linux or find a CD-ROM device driver that treats the CD-R as a normal filesystem. Such applications and drivers are currently rare and difficult to find, although the dropping prices of CD-R units will result in more interest in this type of device. Check an FTP site for recent developments along this line.
If you have just bought a CD-ROM drive or want to add an existing drive to your Linux system, you must follow a series of steps to install and configure the drive properly. This section assumes that you have checked to ensure that Linux supports the drive and that a device driver is available (either in the Linux distribution software or on a separate disk or file).
Although adding a CD-ROM drive to your Linux system may seem to be a daunting task, it is quite simple. Doing the following process will result in a working CD-ROM with a minimum of effort, even if you are not very familiar with Linux:
The following sections describe each of these steps in a little more detail.
Linux doesn't impose any special requirements on the physical installation of a CD-ROM drive. Follow the manufacturer's directions. The instructions for installing your CD-ROM drive should be supplied with the drive itself.
For an internal drive the basic steps are as follows:
External drives are easier to install because you need only add the interface board to an empty slot on the motherboard (assuming you need a new interface board) and attach the cable from the CD-ROM drive to the port on the back of the board. You add SCSI drives to the external SCSI chain. Make sure you have the proper connectors to add the CD-ROM drive to the chain. Also, when adding a SCSI CD-ROM, make sure that you set the SCSI ID to an unused value (see Chapter 7, "SCSI Devices," for more information on SCSI IDs). The SCSI ID is usually set with jumpers on internal CD-ROM drives, although some drives use DIP switches. External SCSI CD-ROM drives use a variety of methods to change SCSI ID numbers. The most popular method is a dial that shows the proper ID.
You must add ISO 9660 filesystem support and the CD-ROM device driver to the Linux kernel to provide support for a CD-ROM drive. Linux requires CD-ROMs to have the ISO 9660 (High Sierra) format, so your Linux system must have ISO 9660 filesystem support built in before the you can use the CD-ROM drive. The Linux ISO 9660 drivers include support for the Rock Ridge Extensions. The ISO 9660 driver is provided as part of the distribution set. Most Linux kernels have the ISO 9660 drivers included automatically when you install Linux from a CD-ROM. You can verify that the drivers are loaded by displaying the boot messages with the following command:
dmesg | more
Examine the lines at the bottom of the output. As shown in Figure 9.1, you will see a line similar to the following
ISO9660 Extensions: RRIP_1991A
if the ISO 9660 drivers are included in your kernel. If you don't see any message about IS0 9660 drivers, add them manually.
If your Linux kernel has the ISO 9660 drivers already linked, you will see a message during startup that shows the extension name.
To add the ISO 9660 driver on most systems, you select a configure option from the Linux setup program or install script. Alternatively, on some Linux systems, you can change to the Linux source directory (usually /usr/src/linux) and perform a
command and select the proper driver from the list presented. After adding ISO 9660 filesystem support, you must relink and rebuild the kernel. See Chapter 25, "Modifying the Kernel," for more information on rebuilding the kernel.
As with all physical devices on a Linux system, a CD-ROM drive requires a device driver. This device driver must be available before you start the installation process. Most popular IDE and proprietary CD-ROM drives have a device driver provided as part of the Linux distribution software. For some CD-ROM drives, you may have to obtain a driver from an FTP or BBS site, or even write it yourself. Whichever method you use, have the device driver file readily available to Linux for this step. If your device driver is on floppy disk, copy it to the /dev directory.
SCSI CD-ROM drives are the easiest to add to a Linux system. If you are adding a SCSI CD-ROM drive, the kernel configuration routine may ask you whether you want to add SCSI support. Answer yes. This question may be followed by a question about SCSI CD-ROM support, depending on the version of Linux you are running. Again, answer yes to this question. Some later versions of Linux with setup scripts enable you to select the CD-ROM drive from a list, as shown in Figure 9.2. When you install Linux from a CD-ROM, the drivers are linked in automatically. Select the SCSI option and continue with the configuration process.
The Linux setup program lets you add support for a CD-ROM.
For IDE and proprietary CD-ROM drives, use the setup or installation routine supplied with Linux. Linux asks you for the type of CD-ROM drive you want to add. Select the drive type that matches your drive, assuming it is on the list. For example, if you are using a Creative Labs CD-ROM drive connected to one of the Creative Labs sound cards, you would select the Matsushita/Panasonic or Mitsumi drive, depending on the type of CD-ROM drive supplied in your package.
If your CD-ROM drive is not on the list presented by the installation or setup script, as is sometimes the case with IDE and some Sony CD-ROM drives, you must manually apply the patch for the drive yourself. If you need to manually patch the kernel, you must rebuild it using the process explained in Chapter 25, "Modifying the Kernel."
If you are using a CD-ROM drive driven by a sound card, you can configure the sound card at the same time as the CD-ROM interface. Some sound cards are not supported by Linux, but their CD-ROM interface is. Check the on-line documentation and FTP/BBS sites for specific information about your sound card.
For the most popular CD-ROM drives, the device files may already be installed in your /dev directory, especially if you used an installation or setup script to add your CD-ROM drive. For other CD-ROM drives, you will have to perform this step manually. Even if the device files were created for you, you should still check the directories manually to ensure that they were installed properly.
To create the device files, you run a command that differs based on the type of CD-ROM drive you are installing. The mknod command is used to create the proper major and minor device numbers (see Chapter 6, "Devices and Device Drivers," for more information on device numbers). For example, you can create a SCSI CD-ROM drive file with the command
mknod /dev/scd0 b 11 0
The device name /dev/scd0 refers to the first CD-ROM drive the kernel finds. A second drive would be /dev/scd1, the third would be /dev/scd2, and so on. Most Linux systems use this naming convention for SCSI CD-ROM drives. The command line indicates that the CD-ROM drive is a block mode device and has a major device number of 11 and a minor device number of 0. A second SCSI CD-ROM drive would have a minor device number of 1; you would add it with the following command:
mknod /dev/scb1 b 11 1
Figure 9.3 shows the /dev/scd device drivers used for a SCSI CD-ROM. Linux usually aliases the device /dev/cdrom to the primary CD device (in this case /dev/scd0), as you can see from the symbolic link.
Two SCSI CD-ROM device drivers are present in most Linux systems.
Proprietary and IDE CD-ROM drives require different device names, and the names vary considerably depending on the model. In most cases, the Linux documentation files that explain supported CD-ROM drives will include the name of the device file to use.
To create a CD-ROM device file for a Matsushita drive (common with Creative Labs and other multimedia add-on CD-ROM drives), use the command
mknod /dev/sbpcd b 25 0
mknod /dev/sbpcd0 b 25 0
This command uses the device driver /dev/sbpcd or /dev/sbpcd0 (the sb portion refers to the Sound Blaster drive card). The device major number is 25, and the minor number is 0. If you have a second drive of the same type, add it as /dev/sbpcd1 with the command
mknod /dev/sbpcd1 b 25 1
You can add more CD-ROM drives of the same type, incrementing the device driver number and the minor device number each time, up to the limit of four CD-ROM drives on the controller. Figure 9.4 shows the device drivers for four Sound Blaster-type CD-ROM drives created by a typical Linux installation. Whether they are used by the kernel depends on the kernel configuration. The device drivers /dev/sbpcd and /dev/sbpcd0 are the same.
By default most Linux versions include four Sound Blaster-type CD-ROM device drivers.
If you use more than one controller for these types of CD-ROM drives, you must create a new major device number (26, 27, and so on) for each controller. Few Linux installations will have more than one CD-ROM drive, let alone more than one controller for multiple CD-ROM drives. In case you're curious, the commands to create a second controller card with two CD-ROM drives of the same type attached are
mknod /dev/sbpcd0 b 26 0 mknod /dev/sbpcd1 b 26 1
A device file for a Sony CD-ROM drive is usually created with the command
mknod /dev/cdu31a b 15 0
which uses the device file /dev/cdu31a (based on the most common Sony CD-ROM drive model, the CDU31A or CDU33A) and has a major device number of 15. Additional CD-ROM drives of the same type would have incrementing minor device numbers. Sony CDU535 and CDU531 CD-ROM drives use a different device driver:
mknod /dev/cdu535 b 24 0
This driver corresponds to the features these models offer.
Mitsumi CD-ROM drives (also popular in multimedia packages) are supported with the command
mknod /dev/mcd b 23 0
which lists the device file /dev/mcd and a major device number of 23. Minor device numbers increment if more than one CD-ROM drive of the same type is used.
If you are supporting two different models of CD-ROM drives on the same system (off two different cards), you must create two device files, one for each drive. For example, if you were running both a Mitsumi and Sony drive, you would issue the commands shown previously for the two drives. Because the major and minor device numbers as well as the device files are different, having two drives poses no problems to Linux.
Once you have created the device files with the mknod command, link the new device driver to the file /dev/cdrom to make the CD-ROM drive easier to access (and the device driver file easier to remember). You can then call the file /dev/cdrom instead of the more complex device file. For example, to link a Mitsumi device file to /dev/cdrom, issue the command
ln -s /dev/mcd /dev/cdrom
Then all references to /dev/cdrom apply to /dev/mcd. Substitute the name of the device driver you have installed for /dev/mcd, of course. When you perform a directory listing of the /dev/cdrom device, you see an arrow after the name showing its link. For example, this entry
lrwxrwxrwx 1 root root 9 Oct 16 15:58 cdrom -> /dev/scd0
shows that /dev/cdrom is symbolically linked to /dev/scd0.
As a last step, if you intend to play audio-only CD discs through the CD-ROM drive you installed, you must make sure the permissions on the device file allow read and write access. You can do this with the command:
chmod 666 /dev/cdrom
assuming you have the /dev/cdrom link set up. Substitute the name of your CD-ROM device driver if you don't use the links.
Now that the kernel has been rebuilt and the device files are properly set, the CD-ROM drive can be tested. Reboot the Linux system and watch the messages displayed when the machine boots. Depending on the type of CD-ROM drive you have added, you should see some status messages that indicate the CD-ROM drive is recognized and communicating properly.
For most IDE and proprietary CD-ROM drives, you see a message similar to Trying to detect a Panasonic CD-ROM drive at... followed by an address. This message tells you that the kernel is searching for what it believes will be a Panasonic CD-ROM device at a particular address. You provided the information about the type of CD-ROM drive and its address when the kernel was configured for the drive. If the CD-ROM is found properly, a message such as 1 Panasonic CD-ROM at... is displayed. Otherwise, you see an error message that tells you the drive couldn't be found.
SCSI CD-ROM device drivers sometimes display status messages, but not always. A typical SCSI CD-ROM message is the following:
Vendor: TOSHIBA Model: CD-ROM XM-3401TA Rev: 1094 Type: CD-ROM ANSI SCSI revision: 02 Detected scsi CD-ROM sr0 at scsi0, id 3, lun 0
This message shows thatthe CD-ROM was configured with SCSI ID 3. In this case, the kernel got the name and model number of the drive from the on-board SCSI electronics (a neat feature of SCSI devices).
If you can't read the messages about the CD-ROM drive when you boot Linux because the screen scrolls by too quickly, you can recover all the boot messages with the command
The dmesg utility tells the kernel ring buffer to show the startup messages. This utility provides a handy way to get help with troublesome devices (not just CD-ROM drives) by sending the output to a file then e-mailing it to a technical support person. If you want, you can pipe the dmesg output to a paging utility like less or more:
dmesg | less
This command lets you scroll backwards and forwards through the startup messages until you find what you are looking for.
If you installed your CD-ROM drive using a script or installation utility, the CD-ROM will probably be mounted automatically due to changes made in the startup commands. If the changes were not made or you installed your CD-ROM drivers manually, you will have to mount the CD-ROM onto your filesystem manually. (You can tell whether the mount was performed automatically by trying to read the CD-ROM directory.) You should mount and unmount CD-ROM drives while you are logged in as superuser (root).
When you mount a CD-ROM drive (or any other device), it is mounted into a subdirectory on the Linux filesystem tree. For convenience, it is useful to mount the CD-ROM drive in a subdirectory called /cdrom (which you must create before you try mounting the CD-ROM there). That way, you can change to the CD-ROM contents quickly. To mount an ISO 9660 CD-ROM on the /cdrom directory, issue the command
mount -t iso9660 -r /dev/cdrom /cdrom
The -t option of the mount command indicates the type of filesystem. The -r option mounts the CD-ROM as a read-only device because you cannot write to it. This option is not strictly necessary, but it prevents many error messages should you accidentally try to write to the CD-ROM disc. The device name /dev/cdrom refers to the device file; if you didn't link to this name earlier, use the actual device file name. Finally, /cdrom is the mount point. You can mount the CD-ROM disk anywhere.
If you receive an error message when you try the mount command, it is probably because the device file doesn't exist or the CD-ROM drive wasn't recognized during startup. Check all the installation information mentioned earlier and try rebooting the system. If you tried to mount the CD-ROM at a mount point that Linux couldn't reach (perhaps because the directory doesn't exist), check the mount point and create it if necessary. The directory you are mounting the CD-ROM onto must be empty.
To test the mount, try changing to the CD-ROM mount point and perform a directory listing. For example, if you mounted the CD-ROM at /cdrom, issue these commands:
cd /cdrom ls
If you get error messages at this point, either there is no disk in the CD-ROM (or it is inserted improperly) or the filesystem is of the wrong type. The error message should give you a clue as to the problem. If you didn't see anything when you performed the ls command, the disk may be improperly spun up, inserted incorrectly, or of the wrong filesystem type. If you did get a directory listing, all is well, and you can move around the CD-ROM disc as if it were part of your normal filesystem (which it is as far as Linux is concerned).
If you want to use the CD-ROM drive to play audio CD discs, the drive should not be mounted. If it is mounted by default, unmount it before playing an audio CD.
To remove a CD-ROM disc or remove the CD-ROM drive from access, you must unmount the CD-ROM drive. You cannot unmount a drive that is currently in use or is being accessed. Also, the CD-ROM drive cannot invoke any processes. To unmount the CD-ROM drive, use the umount command with the name of the mount point (not the name of the CD-ROM device):
This command will unmount the CD-ROM drive and make the directory it was mounted on empty.
Do not change CD discs without unmounting the drive first! When you want to change discs, unmount the CD-ROM drive, change discs, and then remount the drive. If you do not follow this process, the entire Linux filesystem may become corrupt!
Some CD-ROM drives require you to eject the disk caddy with the command
This command helps clear the filesystem table from memory. Most versions of Linux (including the one provided with this book's CD-ROM) do not support the eject command by default, although some CD-ROM drivers can add it.
The /etc/fstab file is used to control the mounting of devices when Linux boots. If you want to mount the CD-ROM automatically every time you start up Linux (if it isn't done already), modify the file /etc/fstab to include the mount. The format of the fstab command for a system mounting two filesystems and a SCSI CD-ROM is as follows:
/dev/sda3 / ext2 defaults 1 1 /dev/sda1 /dos msdos defaults 1 1 /dev/scd0 /cdrom iso9660 ro 1 1
Each line in the /etc/fstab file refers to a different filesystem. Fields on each line must be separated with whitespace (either tabs or spaces). The order of filesystems in the /etc/fstab file is important, as they are followed when the filesystems are mounted or unmounted. Therefore, the primary filesystem must be mounted first, followed by the subsidiary filesystems.
In previous example, the primary Linux filesystem /dev/sda3 is mounted first. It is an ext2 filesystem type. The DOS partition /dev/sda1 is then mounted in the directory /dos, followed by the SCSI CD-ROM drive mounted in /cdrom. If the /dev/sda3 filesystem were not mounted first, the other two commands would fail.
The different fields in the /etc/fstab file are as follows:
If you plan on using a single CD-ROM disc frequently (such as the Linux distribution CD or a disk of utilities), mounting the CD-ROM drive by using /etc/fstab is handy. Modify the fstab file as shown previously, substituting your device device name and mount points.
The mount and umount commands are usually executed only by root. To allow users to mount and unmount CD-ROM drives, you must modify the entry in the /etc/fstab file. Change the entry to read
/dev/scd0 /cdrom iso9660 user,noauto,ro 1 1
The new options on the CD-ROM line allow any user to mount and unmount the drive. The noauto option tells Linux not to mount the filesystem when it first boots, which allows users to change and mount CD-ROMs without worrying about the initial filesystem state. Change the device driver name to match your device name. Alternatively, some utilities allow users to mount and unmount CD-ROM drives without requiring modification to the /etc/fstab file. One, called usermount, is popular and only allows access to CD-ROMs (not other devices), which is useful.
If you want to play an audio-only CD on your CD-ROM drive, you must unmount the filesystem (see the previous section) and have an application capable of playing the disc. Linux includes a number of CD applications, some command-line based and some for the X Window interface. You can get a lot more information about these applications from the documentation that came with your Linux distribution set or from the application's files.
The basic audio CD application supplied with Linux is Workman, which runs under X and lets you move through the audio disc with an on-screen control panel that looks just like a CD player's controls. A character-based version of the program is called WorkBone. Several other applications, such as cdtool, Xmcd, cdplayer, and xcdplayer are also available. More programs are released on FTP and BBS sites regularly, expanding the features supported. Some CD-ROM drives require special versions of the audio CD software, so check the documentation carefully.
If you want to use Kodak's PhotoCD format to view photographs and other images on your Linux system, you need to obtain a PhotoCD utility. Note that not all CD-ROM drives support PhotoCD formats.
The primary PhotoCD utility for Linux is called hpcdtoppm, which converts PhotoCD files to pixmap format. These files can then be displayed using any viewing tool or even saved as use for background for your X session. The photocd utility is similar and can also convert PhotoCD files to Targa and Windows bitmap formats. The utility xpcd, written by the same author as photocd, allows you to examine thumbnail views of pictures stored on a PhotoCD and load them at different resolutions. You can also select specific areas of an image to convert or examine.
If you have installed a CD-ROM drive and configured it properly, yet you still cannot read from the disk, there are a number of potential solutions. Sometimes the problem is simpleyou forgot to mount the drive or misspelled its name. Unless you specifically know the problem, try these solutions in the order that they are presented to isolate the problem's root cause.
Check that the kernel has been relinked and rebuilt with the new CD-ROM device drivers added. You can check the date of the kernel build with the command
If the date doesn't correspond to the date of your linking and rebuilding, the build wasn't completed properly and the CD-ROM drivers are missing. Rebuild the kernel.
Alternatively, you can look at a list of the drivers that are compiled into the kernel by looking at the file /proc/devices. This file lists all the devices, as in the following example:
Character devices: 1 mem 4 ttyp 5 cua 6 lp 7 vcs 10 mouse Block devices: 2 fd 8 sd 11 sr
In this example, the device number 11 refers to the SCSI CD-ROM drive. If you linked in a kernel for a Matsushita CD-ROM, for example, there would be a line in the file that looks like the following:
The numbers in the first column are the major device numbers; the second column has the device driver initials. Check the device numbers you created and compare them to this file. If the major device number is not listed, the CD-ROM driver is not linked to the kernel. Rebuild the kernel.
If the device drivers are linked into the kernel and the CD-ROM device has been mounted but you can't see anything on the disk, try the following command and watch the light on the CD-ROM faceplate that indicates drive activity:
dd if=/dev/cdrom of=/dev/null bs=2048 ^C
Substitute the name of the CD-ROM device if it is not linked to /dev/cdrom. This command tries to copy the contents of the CD-ROM to /dev/null. After issuing the command, issue a Ctrl+C to interrupt it, as the command doesn't really do anything useful. If the drive indicator light blinked or stayed on for a while, yet you still can't read anything on the disk, the disc in the drive is probably not an ISO 9660 filesystem format, or it is ISO 9660 format, but you forgot to link in the ISO 9660 drivers.
Verify that the ISO 9660 drivers are active by examining the contents of the /proc/filesystems file. You should see this line under the nodev section:
If this line doesn't show up in the file, the ISO 9660 device driver is not linked to the kernel. Relink the kernel with this option.
If the ISO 9660 driver is linked in and shows up in the /proc/filesystem file, check that when you mount the CD-ROM drive you specify the option
on the command line.
If you are specifying the ISO 9660 driver and it is linked in to the kernel, chances are the CD is not ISO 9660 format. Try another disc and hope for better results.
If you are having problems with a proprietary CD-ROM drive, chances are the settings for the interface are not correct. The settings are usually defined in a file with the name of the device, such as sbpcd.h for a Matsushita drive. The location of the file varies, so use a wildcard find routine to locate it:
find / -name sbpcd* -print
When you find the file, which usually has a .h extension (such as sbpcd.h), check the contents to ensure that the I/O address, DMA, and IRQ (if applicable) match your card's settings. If you can't find a configuration file, check the settings of the card manually. There may be a conflict with the I/O address, DMA, or IRQ and another device on your system.
If you get device busy errors, and you are running a SCSI system, you may have assigned the CD-ROM device a SCSI ID the same as another device. Check the SCSI IDs.
If you get the device busy message when you try to unmount a CD-ROM drive, then a process is using the drive and is preventing the CD-ROM drive from unmounting successfully. Make sure you are not currently in the CD-ROM directory structure when you try to unmount it. If you can't find the suspect process, use the command
fuser -v /cdrom
to display the processes currently using the device (change the name of the mount point if necessary to match your system).
Despite the amount of information presented in this chapter, adding a CD-ROM drive to your system and properly configuring it can take less than 15 minutes. Unfortunately, the wide variety of proprietary CD-ROM drives means that there will always be a few that are not mentioned in the Linux documentation and will require varying degrees of extra work to properly configure. If you can, stick to one of the major brands that you know is supported. CD-ROMs make a Linux user's life much easier by offering large libraries of utilities and distribution software, and a CD-ROM drive is definitely worth adding to most systems.