CD-ROM and Linux

A CD-ROM drive is one of the most popular hardware upgrades for personal computers and is becoming a standard peripheral for new systems. In the article, Jeff looks at support for CD-ROM under Linux.
Using a CD-ROM

To mount a CD-ROM, insert it in the drive and use the mount command (as root). A typical command line is the following:

% mount -t iso9660 -r /dev/cdrom /mnt

The example above assumes that the CD-ROM device file is /dev/cdrom and the disc is ISO-9660 formatted (this is almost always the case). The -r option indicates that the disc is to be mounted read-only. If successful, the CD can now be accessed under the directory /mnt.

For a more permanent setup, you may wish to mount the CD under a more meaningful name such as /cdrom. By adding an entry to the /etc/fstab file you can have a CD-ROM automatically mounted when Linux boots; see the fstab(5) man page for details.

When finished with the CD, it can be unmounted using the umount command (again, run this as root):

% umount /mnt

If you want to allow non-root users to mount and unmount CD-ROMs, you can use the “user” option provided by some mount commands. If you make an entry such as the following in /etc/fstab:

/dev/sbpcd  /cdrom   iso9660
user,noauto,ro

then an ordinary user will be permitted to mount and unmount the drive using these commands:

% mount /cdrom
% umount /cdrom

The disc will be mounted with some options that help ensure security (e.g., programs on the CD cannot be executed and device files are ignored). Another method is to obtain or write a program such as usermount which runs setuid to root and allows restricted mounting of specific devices (e.g., CD-ROM and floppies) for non-root users.

PhotoCD

PhotoCDs use an ISO-9660 file system to store image files in a proprietary format, at several different resolutions. Not all CD-ROM drives support reading PhotoCDs. If yours does, you can mount it and use a program such as hpcdtoppm to convert the files to a format that can be displayed using graphics file viewers such as xloadimage or xv.

The hpcdtoppm program is part of the PBM (portable bit map) utilities, available on many Internet archive sites (look for pbm or netpbm).

The program xpcd is an X11-based utility for manipulating PhotoCD images. You can select the images with a mouse, preview them in a small window, and load the image with any of the five possible resolutions. You can also mark a part of the image and load only the selected part. This program can be found at ftp.cs.tu-berlin.de in the file /pub/linux/Local/misc/ xpcd-0.2.tar.gz.

Playing Audio CDs

Several programs are available that allow playing audio CDs, either through a headphone jack or an attached sound card. workman, supplied with many Linux distributions, is one such program. It sports a graphical user interface that resembles the controls provided on audio CD players. Simple command-line CD player programs also exist. Note that to play an audio CD you should not try to mount it.

The CD player programs simply route the analog output of the drive to an external device. Some CD-ROM drives also support reading the digital sound data contained on audio CDs. Using a program such as cdda2wav you can save audio tracks from a CD-ROM as a sound file (e.g., in .wav format).

Inheriting File System

The Inheriting File System (IFS) is a kernel driver that allows mounting multiple file systems at the same point. By mounting a hard disk directory over a CD-ROM file system, you can effectively obtain a writable CD-ROM file system.

At the time of this writing, an experimental version of IFS, written by Werner Almesberger for the 0.99 Linux kernel, is available as a kernel patch.

Creating CD-ROMs

If you want to create your own CD-ROM, either by using a writable CD drive or sending a tape to a vendor to be mastered, there are some tools available under Linux that you can use.

The mkisofs package allows creating an ISO-9660 file system on a disk partition. This can be used to assist in creating and testing CD-ROM file systems before mastering discs.

There are also some utilities available for verifying the format of ISO-9660 file systems; these can be useful for checking suspect CD-ROMs.

Getting the CD-ROM HOWTO

______________________

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix