Storage

Installing CD-Writers under Linux

Burn your own CDs on your Linux machine with these instructions on installing a CD-RW drive, building the kernel, and selecting software.


Linux is a popular medium for burning CDs because it’s easy to use and works well when properly set up. It’s also very stable and can be used for copying disks, making audio CDs, and backing up your system on CD-RWs.

This Daily Drill Down is divided into hardware, kernel, and software installation sections. The most important part is the kernel installation, so you should pay particular attention when performing this task.

The hardware section addresses issues related to the CD-ROM drive (CD-RW) installation, the kernel section deals with installing the kernel, and the software section covers the software you’ll need to burn your CDs once everything else is working.

Supported hardware
The list of CD-ROM drives that Linux supports is constantly growing. The list is too long and too technical to include here, but the general rule of thumb is that if it is a SCSI or IDE/ADAPI drive, then it should work. You can check out this comprehensive list of supported hardware (drives). Also check the distribution CD that your Linux software came on for further documentation. You can get the latest hardware compatibility list from Red Hat.

Currently, USB CD-Writers aren't supported at all—at least I haven't been able to find any information on the subject recently. You’ll have to contact your computer manufacturer for any updates, if this is your only option.

You might also take a look at what ZDNet considers the top five drives today. They have a comprehensive database of information on CD-RW drives, so for more information, please visit their Web site. I’ve listed the top five here:
  • Panasonic KXL-RW10A
  • HP CD-Writer Plus 9100I
  • HP CD-Writer Plus 8200I
  • Ricoh MediaMaster MP7040A
  • Ricoh MediaMaster MP9060A

Installing the hardware
After you’ve carefully selected the CD-ROM drive for your Linux box, you need to install it. If your computer already has a CD-ROM drive, then you may want to replace it with the CD-RW drive, since these drives can function as a normal drive—that is, they can read CDs as well as write to them. Replacing the drive will make the installation process a little less complicated, and you can use the old CD drive somewhere else.

If you’re installing a SCSI drive, then you’ll have to read its documentation to figure out the proper installation procedure. Just remember that SCSI drives are numbered 0, 1, 2, etc. and not a, b, c, etc., so the configuration is a little different.

There’s one important factor you need to pay particular attention to. You should set the jumper on the CD so that it will be configured as single or master and not as slave. With the latest kernels, this may not make much difference, though. If you have to configure it as slave and you’re running Red Hat 6.0 or later, then it shouldn’t matter. If your CD-ROM drive has a card, then you may need to set the jumpers or install the drivers that came with the card. Check your documentation. Make sure that you have the cables properly installed with the # 1 pin matched with the corresponding mark on the ribbon cable.

When you’ve put everything back together again, reboot the machine and see if your CD-ROM is detected. If the message scrolls by too quickly for you to read it, you can enter the dmesg command at the command prompt as root to see all the previous messages.

With Red Hat Linux 6.2, your CD-ROM should be detected in the boot-up process. If your CD-ROM was not detected, then you must build the kernel to provide the proper drivers for your device.

What to do if your IDE CD-ROM wasn’t found
If the installation program didn’t find your IDE (ATAPI) CD-ROM, restart the installation and, at the boot prompt, enter linux hdX=cdrom. You’ll need to replace the X with one of the following letters:
  • a—First IDE controller, master
  • b—First IDE controller, slave
  • c—Second IDE controller, master
  • d—Second IDE controller, slave

Then insert the Red Hat Linux CD into the CD-ROM drive and click OK. After a short delay, the installation process will continue.

Rebuilding the kernel
Before doing anything to your kernel, you need to make sure that you have a backup. The best method is to copy your kernel image files to a safe directory so that you can use them later if something goes wrong. You’ll also want to have a boot floppy handy.

The Linux kernel is to Linux what command.com is to DOS. It’s a mediator between the programs and the hardware; it acts as a memory manager, manages processor time for the running programs, and provides a friendly interface so your programs can talk to the hardware. Whenever a new version of the kernel is released or you install new hardware that requires the kernel to have a new driver, you must rebuild and compile the kernel so that it can talk to the hardware.

If you need to upgrade your kernel (if you’re running an earlier version of Linux), then you can obtain the latest source file via ftp:.kernel.org. The latest builds are also available from Red Hat. The source file that you need should be located in /pub/linux/kernel/. Make sure you get the most recent version. To determine your current version, issue the uname -r command.

Now let's build and compile the kernel. Make sure you’re using the BASH shell. If you’re not logged in as root, you should log out and log back in as root or just enter su at the command prompt.

If you’re using KDE or Gnome, then after you log in as root you can type startx to start the graphical interface. We'll use the make menuconfig program, which is a menu-based program that makes things just a little easier with graphics. If you run into trouble, you can turn to the help feature for assistance.

Adding the drivers
Once make menuconfig is running, you’ll see several configuration screens containing a series of questions that you must answer. For these questions, you’ll simply need to answer y, n, or m (for module).

If you’ve already installed Linux and all your hardware and software works, then you’ll need to upgrade only to support your CD-ROM and sound card. You’ll need to change only the items that pertain to those devices. You should check each item carefully, however. Since there are over 400 items to check, it will take awhile.

For example, there’s one question where you can enable the kernel to use the ISO-9660 file system. Practically all CD-ROM drives use this system, so you should answer yes to this question:
ISO 9660 CDROM filesystem support (CONFIG_ISO9660_FS) [Y/n/m?]

If you’re using ATAPI CD-ROM drives, then you can enable support for your drives. You need to answer yes to these questions:
Enhanced IDE/MFM/RLL disk/cdrom/tape support (CONFIG_BLK_DEV_IDE) [Y/n/?)
Include IDE/ATAPI CDROM support (CONFIG_BLK_DEV_IDECD) [Y/n/?]

You should also enable support for your SCSI host adapter. That line should look something like this:
Adapter AHA152X/2825 support (CONFIG_SCSI_AHA152X) [Y/n/n/?]

If you’re running SCSI CD-ROM drives, then you’ll need to answer yes to these questions, too:
SCSI support (CONFIG_SCSI) [Y/n/m/?]
SCSI CDROM support (CONFIG_BLK_DEV_SR) [Y/n/m/?]

To finish the configuration, follow each prompt and answer the questions accordingly. When you’ve entered all the information that you think you’ll need, close the configuration operation and move on to the next step. Now, that wasn't too hard, was it?

When the configuration script ends, it tells you to make dep, which means make dependencies. After doing so, you’ll be asked to make bzImage or make bzdisk, which creates a boot disk. The make bzImage command compiles the kernel; this process usually takes a long time, so don't think that your computer has hung up.

For a more detailed description of the compile process, read the Linux Kernel How-To sections titled “Compiling the Kernel,” “Cleaning and Depending,” and “Compile Time.” Also remember that the make programs have a help facility of their own that you can draw on.

Creating device files and setting the boot time parameters
The Linux kernel uses device files to identify which device driver to use. These files may have been created when you installed Linux on your system. Some Linux distributions have a CD-ROM setup program that allows you to configure your CD-ROM. Other systems come equipped with a /dev/MAKEDEV script. If you see neither of these methods on your installation, then you need to make sure that the device files have been installed. You can find more information about your CD-ROM drive in /usr/src/linux/Documentation/cdrom.

Each CD drive has a different driver or device file. You can create a device file by running the shell commands indicated by your drive type while logged in as root. When Linux is booted, the device drivers attempt to determine whether the appropriate drives or devices are present by checking for specific addresses.

The normal driver for IDE/ATAPI drives is the IDECD driver. The information for this file might look similar to this:
Principal Author: Scott Snyder
Multi-Session support: yes
Multiple drive support: yes
Loadable module support: yes
Reading audio frames: yes
Auto-probing: yes
Device file: /dev/hd(a,b,c,d)
Configuration file: cdrom.h
Kernel config option: Include support for IDE/ATAPI CDROMs?
Documentation file: ide-cd


Of course each driver is different, and the information that you’ll see depends on the particular CD-ROM drive. We use this information to issue a kernel command like the following:
Hdx=cyls, heads, sects, wpcom, irq

or simply,
hda=cdrom

where Hdx means to substitute hda, hdb, hdc, or any other drive. So it would look like hda=cyls, heads, sects, wpcom, irq, and so on.

Next, you need to pass the command line options to the kernel. You must do this from LILO. (A file that explains how to do this is located in /usr/src/linux/Documentation/cdrom/ide-cd.) You’ll need to run LILO from the /sbin/lilo directory.

Some driver files will resemble the following, which is for a Philips Writer:
Device file: /dev/cm206cd
Configuration file: cm206.h
Kernel config options: Philips/LMS CM206 CDROM support
Documentation file: cm206


You can find this information for your particular drive in the /usr/src/linux/Documentation/cdrom/cm206cd directory.

In this situation, you’d issue a kernel command in the following form:
Cm206=<io-address>,<interrupt>

The first number to consider is the I/O base address of the card, such as 0x400, and the second number is the interrupt channel.

You can create this device file by issuing the following at the command prompt:
# mknod /dev/cm206cd b 32 0

If you need more assistance with this section, refer to the Linux Kernel How-To, which explains working with the kernel in more detail.

To load your modules, run the daemon kerneld or kmod, which loads the required modules automatically when the kernel needs them.

Booting the Linux kernel
When you have done all of the previous steps, then you’re ready to boot the kernel. You can shut down the system in the normal safe manner and reboot it. I usually shut it down completely by powering it down after logging out. This way I get a fresh, clean reboot.

As the machine reboots, you should watch for any messages that relate to your CD drive. If they scroll by too quickly, then you can issue either dmesg or tail /var/log/messages to see what was displayed on the screen. If all has gone well, you should see some indication that the drive was detected. If not, then refer to the information at the end of this Daily Drill Down or check out the other resources on your Red Hat Linux distribution disk.

At some point, you should check the kernel to see if it is the new version that you just built or the same old one that was always there. You do this with the uname command, as follows:
% uname -a

You should see a display showing the version you are using. To see what kernel the drivers are compiled in, issue this command:
% cat /proc/devices

Your driver should appear in the list. If all has gone well, then you’re ready to go to the next step—installing software that will allow you to burn CDs.
If you have already installed Red Hat Linux 6.2 on your system, there’s a chance that the kernel already is set up to accept your CD-ROM drive. Try installing the CD-Writer or regular CD-ROM and then rebooting. According to the documentation that comes with the 6.2 distribution, many features, such as PPP and other drivers, are already enabled. If it doesn't work, then you haven't lost anything. You can dig through the documentation to install and rebuild the kernel.
The software installation
When you’re preparing to write to your CD, remember that it usually takes longer to collect the data than to record it. You should also keep in mind that when you write to the CD, it is written to as a whole. This means that you can't go back and rewrite certain files or add files to the CD, like you can with a floppy. This process is similar to copying all the files in a directory to a floppy and then not being able to delete any of them from the floppy.

Another interesting point is that before you can perform a burn to a CD (as with a floppy), it must have a filesystem. This is similar to formatting a floppy or hard disk in DOS. The Linux filesystem is responsible for organizing and incorporating the files that are stored on the medium.

The same utilities that create filesystems on Linux hard disk partitions write an empty filesystem onto them. This filesystem is then mounted and filled with files at the discretion of the user. You can write to a CD only once, so if you write an empty filesystem to it, you cannot go back and add files later. Once you’ve written the filesystem (format) to the disk, then you can go back and mount it, copy files to it, or burn an image to it. As of this writing, the same is true of rewritable media. You can erase only their entire contents, not just a few sectors.

What you need, then, is a tool that can create an entire filesystem (format) while copying files to the disk. There is a tool in Linux that can do this, called mkisofs. Here’s an example of how to use mkisofs:
mkisofs -r -o cd_image private_collection/

After you’ve written the image to the disk, then you should test it to see its status. Linux can mount files just as if they were disk partitions. You can use this to check the directory layout and access permissions so you won't have to worry about it later.

The file cd_image will normally be created in the directory /cdrom. To mount the CD, use the mount command with the following syntax:
mount -t iso9660 -o ro,loop=/dev/loop0 cd_image /cdrom

Now you can use the normal Linux commands, such as ls, to inspect the file. To unmount the CD when you’re finished, just use
umount /mnt/cdrom

Please be aware that this isn't all there is to it. I’ve just shown how to burn a CD. For the complete details, visit your How-To to find out how to really do it all.

What is cdrecord?
Cdrecord allows you to create both audio and data CDs. It’s available for most UNIX platforms, such as Solaris, Linux, and other flavors. Cdrecord supports most CD recorders such as DynaTec, Hi-Val, JVC, Kodak, Philips, Pinnacle, Ricoh, TEAC, HP, Grundig, Mitsumi, Yamaha, Sony, and many others.

The latest stable version that I can find is 1.8.1. Cdrecord is licensed under GPL, and the author is Joerg Schilling. You can download a free copy from Fokus .

Other CD-RW programs
X-CD-Roast is a program package dedicated to easy CD creation under Linux. It combines command-line tools like cdrecord and mkisofs into a nice graphical user interface. BurnIT is a Java front end to cdrecord, mkisofs, and cdda2wav-0.95, making it a complete package for burning CDs on the UNIX platform.

Other needed packages
You’ll need one of the following packages in order to generate images of CD-Rs:

In order to write images to the CD-R, you’ll need one of these software packages:

With the available software choices, you should have no problem getting one of them to work. Your best bet is cdrecord, as it is the most often used and the most tested. By now, you should be familiar with the installation of the hardware and software. So sit back and burn a few CDs while you read more of the documentation about the kernel.

Conclusion
In this Daily Drill Down, you have learned how to install a CD-RW drive, build the kernel, and select the software that will allow you to burn your CD masterpiece.

Dallas G. Releford has worked in the computer field as a programmer, an MIS manager, and a PC specialist. He has written a novel, which was published on the Internet and which led him to an interest in the electronic publishing field. He writes articles, electronic books, and just about anything else that involves the written word. To learn more about Dallas’ business, visit his Web site, which is called The Editor’s Eye .

The authors and editors have taken care in preparation of the content contained herein but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.

Editor's Picks

Free Newsletters, In your Inbox