Troubleshooters.Com and T.C Linux Library Present

Installing Your ATAPI CDRW Drive in Linux

Copyright (C) 2001-2002, 2004 by Steve Litt
[ Linux Library | Troubleshooters.Com | Email Steve Litt | Copyright Notice ]
[ See also Coasterless CD Burning ]

Contents:

Executive Summary


WARNING

A lot has changed since this document was written. I found a better method of reading CD devices, and the 2.6 kernel has changed the dev= argument to the cdrecord command. I suggest you read the Coasterless CD Burning document along with this one.

The purpose of this document is to give you the step by step procedure for installing and setting up an ATAPI CD rewriter on a Linux computer.  The basic steps are:

Disclaimer

Obviously, you use this document at your own risk. I am not responsible for any damage or injury caused by your use of this document, or caused by errors and/or omissions in this document. If that's not acceptable to you, you may not use this document. By using this document you are accepting this disclaimer.

Gotcha!

Some high performance IDE ports do not work with IDE CDRW drives. In my case, I've seen that attaching a CDRW to IDE3 or IDE4 of an Abit BP6 (Ultra DMA 66) hang the machine so hard that nothing short of a powerdown regains control.

So I'd recommend you try to get your CDRW running on a normal IDE port before attempting it on a high performance port.
 

Physical Installation

ALWAYS OBSERVE STATIC ELECTRICITY CAUTIONS. ALWAYS TURN THE POWER SUPPLY'S SWITCH TO 0 IF IT HAS ONE, OR IF IT DOESN'T HAVE ONE UNPLUG THE UNIT FROM THE WALL.

Decide whether this drive will be a master or a slave. In deciding where to put this drive, please remember that simultaneously running two drives on the same IDE cable severely degrades the performance of both. If you don't do a lot of CD to CD duping, you might want to put your CDRW on the same IDE cable as your readonly CD drive.

Once you've set the jumpers for master or slave (I use master if it's the only one on the cable), with the power supply switch set to 0, or if there's no power supply switch with the computer unplugged, slide the CDRW drive into the bay, connect both power and IDE cable. Be sure to get polarities right. Take care not to bend any IDE connector pins. Be sure to remember which IDE port you've connected it to, and whether it was a master or a slave. Note that you might need to rejumper the master/slave status of the device that was already on the cable.

Once all connections are made and checked, place the unit right-side-up, plug it into wall current, switch the power supply switch to the 1 position, and power up the computer.

Testing the Device

Your first task is to determine the device name. Refer to the chart below:
 
IDE Port  Master/slave  Device
1 master /dev/hda
1 slave /dev/hdb
2 master /dev/hdc
2 slave /dev/hdd
3 master /dev/hde
3 slave /dev/hdf
4 master /dev/hdg
4 slave /dev/hdh

For the rest of this document, all examples will be /dev/hdc (master of 2nd IDE port). Modify these examples to fit your machine.

Unless the device itself works, no CDRW functions will work. So start by confirming that the device works. With no CD in the CDRW tray, and no mount of the CDRW, and the CDRW tray in the closed position, perform the following command:

eject /dev/hdc
If the CDRW tray opens, the device works. Otherwise it doesn't. Troubleshooting includes making sure you really used the master/slave jumper setting you thought you did, and making sure power and IDE cable are correctly connected. You might try the command with /dev/hda through /dev/hdh just to make sure the CDRW isn't connected differently from what you thought.

TIP

By far the easiest way to test your hardware is to boot to a Knoppix CD. If your CDRW is installed correctly, Knoppix should detect it and enable you to burn CD's. Once the CDRW is working in Knoppix, you know your hardware is working right. Additionally, you can learn a lot by looking at the various config files from within Knoppix.

Once you have your CDRW drive ejecting, it's time to configure its SCSI simulation...

Configuring the SCSI Simulation

NOTE

Most modern Linux distributions work "right out of the box" when installed on a machine with a correctly wired up CDRW drive. If you plan on doing a reinstall in the near future, consider putting in the CDRW beforehand, and then installing. This can save considerable trouble.

Another tip is to boot Knoppix, verify that you can burn CD's from within Knoppix, and study the Knoppix CDRW configuration.

ATAPI IDE CDRW drives work with SCSI simulation, which must be configured. You must know the device (i.e. /dev/hdc) in order to make this configuration. For the purposes of this example, let's say it's /dev/hdc.

Modifications to /etc/modules.conf

Start by backing up your original /etc/modules.conf. Then add the following line to /etc/modules.conf:
alias scsi_hostadapter ide-scsi
Note that depending on your distribution, the line might be required to look like this instead:
alias scsi_cd ide-scsi
I've never seen it necessary, but there are those that say the following is sometimes also a necessary addition to /dev/hdc:
options ide-scsi ignore=hdc
Don't include the preceding line unless you can't get your CDRW to work without it.

Modifications to /etc/lilo.conf

 
WARNING!

Before modifying /etc/lilo.conf, make sure you have a boot diskette that will boot your system. Test it. If you don't, make one with the mkbootdisk program!

Accidents happen, and if you mess up /etc/lilo.conf without a boot disk, you will encounter extreme difficulties getting your system to boot.

Start by backing up your original /etc/lilo.conf. Note that lilo.conf has several images, each of which can be booted. In each boot image you wish to recognize the CDRW, check lilo.conf to see if it has an append= line. It might look something like this:

append=" devfs=mount quiet"
Because each image can have only one append= statement, you must append hdc=ide-scsi to the existing statement, like this:
append=" devfs=mount quiet hdc=ide-scsi"
In the preceding, please remember to substitute hda, hdb, hdd, etc. for hdc as appropriate for the CDRW's device.

If a boot image does not have an existing append statement, add the following line to the boot image.
add the following line to /etc/modules.conf:

append="hdc=ide-scsi"
After you've saved your modifications, run lilo. It should look something like this:
 
[root@mydesk /etc]# lilo
Added mand *
Added linux-up
Added failsafe
Added floppy
[root@mydesk /etc]#

If there are error messages, DO NOT reboot until you've fixed them. Once there are no error messages, reboot the system. If it doesn't boot, boot it with the bootable floppy you made earlier, back up your lilo.conf, and then copy the original lilo.conf on top of the one you modified. Then run lilo again. You should once again be able to boot without the floppy.

Recognizing the CDRW

 
NOTE:

On some Linux distributions, /usr/bin/cdrecord is not executable by all, and so only works for root. To use it as a normal user you must chmod it to be executable by all, or else executable by group, chgrp it to a different group, and then place all users required to use it in that group.

I don't know whether the original mode of cdrecord was an oversight, or whether it was done for security.

Try the following command:

cdrecord -scanbus
If you're lucky, it will give you a SCSI device number for the CDRW, as in the following example:
 
[root@litttest root]# cdrecord -scanbus
Cdrecord 1.10 (i586-mandrake-linux-gnu) Copyright (C) 1995-2001 Jörg Schilling
Linux sg driver version: 3.1.20
Using libscg version 'schily-0.5'
scsibus0:
        0,0,0     0) 'CyberDrv' 'CW038D CD-R/RW  ' '100C' Removable CD-ROM
        0,1,0     1) *
        0,2,0     2) *
        0,3,0     3) *
        0,4,0     4) *
        0,5,0     5) *
        0,6,0     6) *
        0,7,0     7) *
[root@litttest root]#

Typically you won't get lucky right after the install. Your results might look more like the disappointing results below:
 
[root@litttest root]# cdrecord -scanbus
Cdrecord 1.10 (i586-mandrake-linux-gnu) Copyright (C) 1995-2001 Jörg Schilling
cdrecord: No such file or directory. Cannot open SCSI driver.
cdrecord: For possible targets try 'cdrecord -scanbus'. Make sure you are root.
[root@litttest root]#

Results like the preceding are typically caused by ide-scsi, scsi_cd or similar modules not being loaded or not being loaded correctly. Run the rmmod command several times until told it's not loaded:
 
[root@litttest root]# rmmod ide-scsi
[root@litttest root]# rmmod ide-scsi
rmmod: module ide-scsi is not loaded
[root@litttest root]#

Now load the ide-scsi module as follows:
 
[root@litttest root]# insmod ide-scsi
Using /lib/modules/2.4.8-26mdk/kernel/drivers/scsi/ide-scsi.o.gz
[root@litttest root]#

Then run cdrecord -scanbus again. If it presents you with a SCSI device number, continue to the next section. Otherwise, review all the configuration steps and try variations on /etc/modules.conf. Be sure after changing /etc/lilo.conf you really ran lilo, and ran it successfully.

Burning a CD from an ISO Image

Once the cdrecord -scanbus command returns a SCSI device number, you should be able to burn a CD from an ISO image. Find a known good ISO image file. For this example we'll use Mandrake81-cd1-inst.i586.iso. You must also know the maximum speed of your CDRW, and the specified speed for the media you're using. If your CDRW is 16x write, 12x rewrite and 40x read, its maximum speed is 16x if you're using a write-once blank CD, but it's 12x if you're using a rewriteable CD media. Furthermore, if the medium is not guaranteed to that maximum, then the real maximum speed is the guaranteed speed of the medium. For instance, with the 16/12/40 CDRW, if you're using a 24x write-once blank, the maximum speed is 16x. But if you're using a 12x write-once blank, the maximum speed is only 12x.

Once you know the SCSI device number, the maximum speed and the filename of the ISO image, you can burn the CD. Assuming the info in the preceding paragraph, with the SCSI device number being 0,0,0, and a 16x write-once blank CD, the following command should burn the CD:

cdrecord dev=0,0,0 speed=16 -pad -v -eject Mandrake81-cd1-inst.i586.iso

WARNING

Notice the -pad option in the preceding command. Without it, this CD will not read correctly on some computers. This is  due to the well documented "ISO-9660 filesystem read ahead bug". You can read about this bug on the cdrecord man page, in the padsize= section.

KERNEL 2.6 WARNING

The 2.6 Linux kernel substantially changes the way CDRW drives are accessed, and you might find that your cdrecord command no longer works. Specifically, with the 2.6 (and probably later) kernel, you might need to prefix your device with the string ATA: like this:

cdrecord dev=ATA:0,0,0 speed=16 -pad -v -eject Mandrake81-cd1-inst.i586.iso

If the CD does not burn and eject, you need to troubleshoot, and that troubleshooting is beyond the scope of this document. You might want to reduce the speed to 2x and see if that makes things better. As stated before, make sure the CDRW is connected to a normal IDE port, not an enhanced port.

If the CD burns and ejects, you're not done. You must compare its contents to the original file.

Testing the CD for Accuracy

See the Testing article in the Coasterless CD Burning web page.

Mastering Your Own ISO Image

Most of the time you need to master your own ISO image. There are many ways to do this. The simple command line method is to use mkisofs. You should take an hour to familiarize yourself with its man page. The following is a command to place a single 8.3 file (in this case backup.tgz) into the ISO image (called backup.iso):
mkisofs -pad -o backup.iso backup.tgz
You can test the ISO image as follows:
 
[root@mydesk slitt]# mkdir /mnt/test
[root@mydesk slitt]# mount -o loop -t iso9660 backup.iso /mnt/test
[root@mydesk slitt]# diff /mnt/test/backup.tgz backup.tgz
[root@mydesk slitt]#

In the preceding steps, notice that the diff command gave no output, indicating that the copy of backup.tgz inside the ISO file is identical to the original.

Be aware that mkisofs has *many* options. Some crucial ones are rockridge and joliet extensions, which enable long filenames. Joliet extensions make the CD a Windows like CD. There are extensions for Macintosh compatibility. And there are many, many more.

Also be aware that often the easiest way to master an ISO is with a higher level program such as

Summary

Getting an IDE ATAPI CDRW working in your Linux box is a process. If all goes well the process is rather straightforward and goes something like this: Also included in this document is an overview on mastering your own .iso files.


See also: [ Linux Library | Troubleshooters.Com | Email Steve Litt | Copyright Notice ]

Copyright (C)2001-2002, 2004 by Steve Litt. -- Legal