ALINK="#FF0000">

LINUX GAZETTE

[ Prev ][ Table of Contents ][ Front Page ][ Talkback ][ FAQ ][ Next ]

"Linux Gazette...making Linux just a little more fun!"


CD-Writing with an ATAPI CDR Mini-HOWTO

By Chris Stoddard


This document provides the least amount of information needed to get an ATAPI CDR running under Linux.

Table of Contents

1. Introduction

The documentation for getting a CDR up and running under Linux is an excellent piece of work, however, if all you want to do is burn a few MP3's the documentation can be overwhelming. I'm going to attempt to boil installing and configuring a CDR down to as few steps as necessary to get the job done. I will be focusing only on ATAPI drives as SCSI drives work well with out too many problems. The information here was culled from 4 hours of trial and error as well as the CD-Writing-HOWTO.

2. Installing the Hardware

The first thing to do, even before you buy the drive is to check the hardware compatibility list. Things will go easier for you if your drive is listed. If it is not, don't despair, my Iomega ZIPCD is not on the list, but still works fine. Any ATAPI CDR "should" work, should being the key word here.

I'm not going into much detail about installing the hardware, if you don't know how to install your drive or you don't understand what I'm talking about, please get some one to help you. I have found I get the best results by jumpering the drive to slave and connecting it to the same IDE cable as your CDROM. Make sure your BIOS recognizes the new drive and when the system boots make sure it is recognized as an ATAPI drive, if it is not, this will never work. After the system boots up, check your kernel messages to see if the drive is properly recognized by typing "dmesg | grep ATAPI" at the command line, you should see something like this;

  hdc: FX162N, ATAPI CDROM drive
  hdd: ZIPCD 4x650, ATAPI CDROM drive
  hdc: ATAPI 16X CD-ROM drive, 128kB Cache
  scsi0 : SCSI host adapter emulation for IDE ATAPI devices

Make note of the device name Linux gives your drive, my ZIPCD is recognized as hdd by the kernel, this becomes important later.

3. Loading the drivers

Before getting started, you must be able to log into the system as root to preform these steps. Make sure cdrecord and mkisofs are installed on the system, to do this type "rpm -q cdrecord mkisofs", this will tell you if the packages are installed or not, if they are not, you will need to install them. Also make sure the ide-scsi module is present, to verify this, type "ls -lR /lib | grep ide-scsi". If the module is not present you will need to recompile the kernel, which is beyond the scope of this document. We now need to get the proper drivers installed and loading at boot time. Open /etc/rc.d/rc.local and add the following line, to the end of the file, then save and exit the file.

  /sbin/insmod ide-scsi

Next we need to configure the drivers so they work properly Open /etc/conf.modules and add the following lines at the bottom;

  alias scd0 srmod
  alias scsi_hostadapter ide-scsi
  options ide-cd ignore=hdd

On the final line, notice I placed the device name of my ZIPCD, replace hdd with the device name of your CDR. Save the file and exit. To associate the driver with the proper drive, open /etc/lilo.conf, add the following line, right before or right after the "root=" line;

  append="hdd=ide-scsi" 

Save the file and exit, rerun lilo by typing "/sbin/lilo" at the command line. Now reboot the system. Once it has come back up type "dmesg" at the command line, if all went well the last few lines should look similar to this;

  scsi0 : SCSI host adapter emulation for IDE ATAPI devices
  scsi : 1 host.
    Vendor: IOMEGA    Model: ZIPCD 4x650       Rev: 1.04
    Type:   CD-ROM                             ANSI SCSI revision: 02
  Detected scsi CD-ROM sr0 at scsi0, channel 0, id 0, lun 0
  sr0: scsi3-mmc drive: 24x/24x writer cd/rw xa/form2 cdda tray
  VFS: Disk change detected on device ide1(22,0)

You should now be able to use cdrecord, to test this, type "cdrecord -scanbus" at the command line, output should look something like this;

Cdrecord release 1.8a29 Copyright (C) 1995-1999 Jorg Schilling
scsibus0:
   0,0,0       0) 'IOMEGA  ' 'ZIPCD 4x650     ' '1.04' 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) *

Please note the three numbers separated by commas to the left of where your drive is listed. These numbers will be used in cdrecord's command line. If you get an error message, try going over the steps again and make sure you have the correct device name for the CDR. Read the CD-Writing-HOWTO, there are a few tricks to try listed in this file. If it still does not work it is possible your drive is incompatible.

4. Quick and dirty Burn

To burn a CD you will need to log in as root, if you want any user to be able to burn CD's type the following command, "chmod +s /usr/bin/cdrecord". Burning a CD in Linux is a two step process, first you must make the image, this is done with mkisofs. The syntax for mkisofs is;

  mkisofs -r -o image.img /folder/to/burn/

Make a new directory and copy all the files you want to burn into this directory. As an example I make a directory in my home directory called mp3, I then copied about 600MB worth of MP3's into the folder. To make my image I typed the following;

  mkisofs -r -o mp3_cd.img /home/chris/mp3/

After a few moments I have a 600MB CD image named mp3_cd.img. The second step is burning the image to the CD. This is done with cdrecord To burn my image I type the following;

  cdrecord -v speed=4 dev=0,0,0 -data mp3_cd.img

The speed option should be set to the highest speed your drive will take, mine is a 4x burner, older drives may only be 1x or 2x, newer drives can be up to 8x or even 12x. The dev option can be had from "cdrecord -scanbus", which we ran earlier, my drive appeared next to 0,0,0 you should use whatever your drive appears next to. Again several minutes later I had a newly burned CD. For further information on mkisofs and cdrecord and their many options, please read the documentation.

5. Final Note

To use the drive as a normal cdrom, you must keep in mind the system now thinks your drive is a SCSI device, the device name is no longer hdd, it is now scd0. Go into the /dev directory and make a link, type "ln -s scd0 cdr", then go to /mnt and type "mkdir cdr". Move to the /etc directory and open fstab and add the following line right under the entry for the cdrom;

  /dev/cdr     /mnt/cdr     iso9660 noauto,owner,ro 0 0

Now you can mount the drive the same way you mount the cdrom, something like "mount -t iso9660 /dev/cdr /mnt/cdr".

[There is another article about CD recording in this issue. -Mike.]


Copyright © 2000, Chris Stoddard
Published in Issue 57 of Linux Gazette, September 2000

[ Prev ][ Table of Contents ][ Front Page ][ Talkback ][ FAQ ][ Next ]