This guide describes setting up
a CD-Writer on Linux. The definitive guide is the CD-Writing HOWTO
. This page is for those anxious to get started quickly.
I set up my first CD-Writer about 4 years ago. A few things have
changed since then, but the basic principles are the same and I've
never had need to change my setup. Below, I'll describe how I do
things. Others may do it a little differently, and that's fine.
What We're Going To Do
- We're going to create a setup where you always access your
CD-ROM/CDRW drives as IDE drives and only switch to SCSI when we need
to write CDs.
- There are ways around this (eg. passing hdc=ide-scsi on the
command line where hdc is your CDRW drive) but those won't be covered
here.
- Both your IDE drivers and your Generic SCSI drivers will be
compiled as modules.
What You Need
- An IDE-ATAPI CD-Writer (This guide does not cover SCSI.
Actually, SCSI is a lot easier)
- Generic SCSI support in your kernel. This lets you send
SCSI commands to your CD-Writer. Things will not work without this. It's unlikely that your
kernel has this compiled in by default. If it doesn't, then you'll need
to know how to compile a kernel. The Kernel HOWTO
covers this. This guide assumes you don't have generic SCSI support.
- The cdrecord and mkisofsprograms for creating CD data Images and
writing them to disk. Most distributions come with these programs
nowadays. If you don't have them, search for them on freshmeat.
Setting Up The Drive
- First, you need to enable
generic SCSI support in the kernel. Switch to your kernel source
directory (usually /usr/src/linux) and do a "make menuconfig" or a "make
xconfig"
- Go to the IDE/ATA/MFM/RLL
support menu and then the IDE, ATA and ATAPI Block devices submenu
- Compile IDE/ATAPI CDROM Support and SCSI Emulation Support as
modules
- Next, from the main menu, go to the SCSI support menu and compile SCSI
support into the
kernel. In the same menu, compile SCSI
CDROM support
and SCSI generic support
as modules
- Save your
configuration, do a make bzImage, make modules, make install and make
modules_install and restart your machine with the new kernel
- The script load_scsi below removes IDE CDROM support from your
kernel and loads scsi support. The unload_scsiscript removes scsi support. The IDE
CDROM drivers are used by default when you attempt to access the CDROM
drive. Make these scripts executable and put them somewhere in
your path
|
load_scsi script
|
#!/bin/sh
#script to load scsi modules into kernel
#make these variables point to the mount points of your cdrom/cdrw
devices
mount_point1="/mnt/cdrom"
mount_point2="/mnt/cdrom2"
mount_point3="/mnt/cdrom3"
#no need to edit anything below this point
if [ ! "$mount_point1" = "" ];
then
umount ${mount_point1}
fi
if [ ! "$mount_point2" = "" ];
then
umount ${mount_point2}
fi
if [ ! "$mount_point3" = "" ];
then
umount ${mount_point3}
fi
#remove ide cdrom support
rmmod ide-cd
#enable scsi support
modprobe ide-scsi
modprobe sg
modprobe sr_mod
|
unload_scsi script
|
#!/bin/sh
#script to remove scsi support from the kernel
rmmod ide-scsi
rmmod sg
rmmod sr_mod
|
- Edit the load_scsi script and set the mount_point1, mount_point2 and
mount_point3 variables to point to where you mount your
cdrom/cdrw drives
- Once the scripts are in your path, to enable SCSI support
in your kernel and write CDs, just type load_scsi as root
- You can verify
that your CD writer is working by typing cdrecord -scanbus. If you see your CD-Writer listed as one
of the recognized drives, everything's OK. The output I receive after
running load_scsi is shown below as an example:
|
Cdrecord
1.11a24 (i686-pc-linux-gnu) Copyright (C) 1995-2002 Jörg Schilling
Linux sg driver version: 3.1.24
Using libscg version 'schily-0.6'
scsibus0:
0,0,0 0) 'HP '
'CD-Writer+ 8100 ' '1.0g' Removable CD-ROM
cdrecord: Warning: controller returns wrong size for CD capabilities
page.
0,1,0 1) 'SONY '
'CDU4811 ' 'PY09'
Removable CD-ROM
0,2,0 2) *
0,3,0 3) *
0,4,0 4) *
0,5,0 5) *
0,6,0 6) *
0,7,0 7) *
|
- You're now ready to write CDs
- If something went wrong, your output should look similar to
the listing below. Have a look at the CD-Writing HOWTO
for possible reasons and fixes.
|
Cdrecord
1.11a24 (i686-pc-linux-gnu) Copyright (C) 1995-2002 Jörg Schilling
cdrecord: No such file or directory. Cannot open '/dev/pg*'. Cannot
open SCSI driver.
cdrecord: For possible targets try 'cdrecord -scanbus'. Make sure you
are root.
|
Writing CDs
|
- mkisofs is used
to create a CD image
- cdrecord is used
to write the image to a blank CD (or a rewritable CD)
- The man page for cdrecord
and the mkisofs man page
contain full descriptions of how to use those programs
- cdrecord can
also write audio tracks by passing it the -audio flag and possibly a
few other flags as well. An alternative application used for writing CD
audio data is cdrdao.
- A number of fancy frontends for these applications exist,
and if you're using a major distribution, you most likely have all the
applications including at least one frontend installed. All these
programs are available at freshmeat
as well.
|
Sample CD-Writing Commands
From the output of cdrecord -scanbus above, I see that my CD-Writer
drive is identified as SCSI device 0,0,0
|
| 0,0,0
0) 'HP ' 'CD-Writer+ 8100 ' '1.0g'
Removable CD-ROM |
The command below takes the contents of the /uploads directory, creates
and image and pipes that image to cdrecord. This way I don't store the
actual image on my hard drive and waste space. I have to check that
/uploads contains less than 650MB (or 700MB if you have a better drive
than me). The image is created with Rockridge extensions (-r -R),
symlinks are followed (-f) and long filenames are supported (-l). The
image is written at 4x (speed=4) and multiple sessions are supported
(-multi)
|
mkisofs
-v -l -f -r -R /uploads | cdrecord dev=0,0,0 speed=4 -v -multi -
|
The next command only creates a CD Image and stores it to the hard
drive as the file ~/myimage.iso
|
mkisofs
-v -l -f -r -R -o ~/myimage.iso /uploads
|
Lastly, the following command can be used to write an image (eg. a
downloaded ISO image or one created with mkisofs) to disk:
|
cdrecord
dev=0,0,0 speed=8 -v -multi some_image.iso
|
Enjoy!!!
|