Google

Burning CD's with Linux

Burning CD's with Linux

Contact:[email protected]

Learn to Burn
Mastering your CDs Under Linux

by Steve Hanson

So, at age six you dreamed of being a big, burly fireman performing daring
rescues from blazing buildings. Now you'd simply like to accomplish today's
version of Disco Inferno, a controlled burn of those MP3s to CD-Audio in
Linux. Don't despair, Sparkie! It's really not your fault that you can't get
your burning sessions completed on your Linux box. You haven't read this red
hot article yet!

Grab your oxygen mask and those blank CDs gathering dust under your desk and
get ready to rescue your reputation as a computer whiz which, until this
issue of Maximum Linux, had been lying in the ashes. We'll teach you the ins
and outs of burning CDs under Linux, and soon you'll be able to satisfy all
those burning desires. Tell your gals and pals you can now burn them copies
of Britney Spears' latest release. Don't forget to stock up on Tums and get
ready to burn, baby, burn!


The Linux Advantge
Although installing and configuring Linux gets easier all the time, some
hardware items continue to be a bother. Burning CDs is one thing that people
really want to do with their computers, but getting this to work under Linux
is still problematic. With Linux, it can be easy to make CDs reliably from
audio, data, and MP3s. Most of the common distributions include some sort of
low-level software for this purpose, however, many are difficult to
configure and use. We're going to explore why CD burners can cause problems
and how you can make your CD-R drive work efficiently with Linux.

Linux does have some advantages over Windows when it comes to mastering and
burning CDs. For starters, there is that large range of software for CD
burning we mentioned, and, of course, most of it is free. Linux also tends
to be considerably more stable than Windows. Our old Memorex CD-RW drive
barely works with Windows, and creates a fair number of coasters. Under
Linux, it is much more reliable, and we never seem to get buffer underruns.
Linux can feed data more reliably to the drive because it is a
higher-performance OS, and CD-burning programs can set their priorities high
enough so that you can actually do a fair amount of work on the computer
while simultaneously burning CDs. Keep in mind that, like anything else,
there's no such thing as a free lunch, and getting your burner to work in
Linux may require rolling up your sleeves, cracking your knuckles, and
getting downright physical with your equipment.

She's Got Issues
There are a few issues in play when it comes to burning CDs--whether it's in
Windows or in Linux. The biggest stumbling block is that the most
inexpensive CD-R drives on PC systems use the IDE interface to connect to
the computer. The original IDE standard was intended to work with normal
hard drives, and was later extended with ATAPI extensions, which allowed the
use of tape and CD-ROM drives on IDE interfaces. The ATAPI extensions can
either be accessed through a direct IDE programming interface or through a
more flexible set of interfaces that makes the drive appear to be a SCSI
device. Under Linux, CD-R-burning software treats IDE-based CD-R drives as
SCSI devices, so systems with IDE are more of a challenge. The workaround
(in Linux and Windows) is done by fooling the operating system into thinking
the IDE drive is really a SCSI drive. This is generally accomplished by
emulation software. If you're doing this on a Windows machine, no sweat--the
installation of Windows-based CD-burner software usually includes special
drivers to perform the SCSI emulation.

Under Linux, however, things aren't as rosy. Until the day comes when your
new CD burner is packaged with something such as Adaptec's Easy CD Creator
for Linux, you'll have to learn to roll your own. This isn't terribly
difficult, but it isn't documented with your Linux distribution, and any
docs that do exist may be difficult to understand. If you have a SCSI drive
and you SCSI card is supported by Linux, you can skip over some of this.

What Do You Need?
Linux Kernel

First of all, you'll make your own life a lot simpler if you're running a
recent version of Linux. Any of the current distributions should do the job.
You should make absolutely sure you're running a Linux kernel later than
2.0.36. In general, you'll find everything works smoothly if you use a
kernel later than 2.2.10. The examples we give later in the article apply
directly to either a Red Hat 6.1 or 6.2 system, and all the software
described here was tested on both 6.1 and 6.2.

CPU and Memory

Although you don't need the latest hardware to burn CDs, it helps not to
have an ancient box with a slow CPU and very little memory. The testing for
this article was done on a K6-2 450MHz system with 64MB o' memory. In case
you were wondering, no, you don't need to have access to a state-of-the-art
system--we've happily burned CDs in Linux on a 166MHz Cyrix-based system
that had a measly 32MB of memory. Just don't try this on your old 386SX
system, or on a machine with only 8MB of RAM--you'll only make yourself a
nice set of silver coasters.

SCSI Drives

Assuming you're taking the recommended easy way out and using a SCSI drive,
there are a few requirements that you'll need to meet first. Make sure that
Linux supports your SCSI adapter. Most cards are supported, but if you have
the very latest model, there may not be a working driver available just yet.
You should also check to see if your drive is known to work with Linux.
(Check the Resources section).

You'll also need to ensure that the generic SCSI and SCSI CD-ROM drivers are
available in your kernel, along with the driver for your particular SCSI
adapter. If you're using a stock Red Hat 6.1 or 6.2 installation, you're
probably okay �out of the box,� as these drivers should already be
available. They may be compiled directly into the kernel or be loadable
modules.

The following table lists the configuration parameters you should have set
to build a kernel to support a SCSI drive:


   :

Parameter  Section  Module  Setting
Enhanced IDE/MFM/RLL BLOCK   ?
IDE/ATAPI CD-ROM BLOCK  ide-cd ?
SCSI Host adapter Emulation BLOCK  ide-scsi ?
Loopback Device BLOCK  loop M
SCSI Support  SCSI scsi_mod Y/M
SCSI CD-ROM Support SCSI sr_mod Y/M
Enable vendor-specific SCSI  Y
SCSI Generic Support SCSI sg Y/M
Low Level Driver SCSI  Y/M
Iso9660 CD-ROM Filesystem FS iso9660 Y
Microsoft Joliet CDROM FS joliet Y/M

Y=YES, N=NO, M=MODULE, ?=DOESN'T MATTER


IDE Drives

If you have an IDE/ATAPI CD-R drive, you'll need to build a special kernel.
You need to be sure (yes, we know this sounds strange) that you do not have
the IDE CD-ROM driver installed in the kernel and that you do have SCSI
emulation turned on. Remember, we're going to pretend the CD burner is a
SCSI device. And, as far as the OS is concerned, it'll appear to be one--but
only after completing the following step.

The following table lists the settings you will need in order to configure
your kernel appropriately:


   :

Parameter  Section  Module  Setting
Enhanced IDE/MFM/RLL BLOCK   Y
IDE/ATAPI CD-ROM BLOCK  ide-cd N
SCSI Host adapter Emulation BLOCK  ide-scsi Y?N
Loopback Device BLOCK  loop M
SCSI Support  SCSI scsi_mod Y/M
SCSI CD-ROM Support SCSI sr_mod Y/M
Enable vendor-specific SCSI  Y
SCSI Generic Support SCSI sg Y/M
Low Level Driver SCSI  Y
Iso9660 CD-ROM Filesystem FS iso9660 Y
Microsoft Joliet CDROM FS joliet Y/M

Y=YES, N=NO, M=MODULE, ?=DOESN'T MATTER



Small Steps, Small Steps

Even if you have big feet, we encourage you to take tiny baby steps to set
up your burner. Take things too fast, and you could end up singeing your
nose-hairs. We'll use an IDE drive as an example, because setting this up
can be one of the most complicated tasks known to mankind.

Configure Your Kernel

First, you'll have to configure the kernel compilation. This will apply
directly to a Red Hat 6.1 or 6.2 system, but other distributions will be
very similar. You'll need to take a standard kernel configuration as it
ships with the distribution and modify it to remove support for ATAPI CD-ROM
drives. While you're at it, you may as well set up the SCSI emulation, too.
The easiest way to do this is to use the xconfig system to set up a kernel
configuration. So, let's first become root:

# su
Password: (type your root password here)
#

Now, cd to the kernel source, and use the make system to start up the
xconfig system:

# cd /usr/src/linux
# make oldconfig (This will build a configuration like the default)
# make xconfig

This will start up the xconfig program, which you'll use to set the kernel
parameters. The make program will display a kernel configuration menu, from
which you can set all the different kernel build parameters. On a normal Red
Hat 6.1 or 6.2 installation, you should drill down through the menus and
make sure that the following parameters are set (assuming you're using an
IDE/ATAPI drive):

Block devices -> Include IDE/ATAPI CDROM support = n

Block devices -> SCSI emulation support = y

If you're using a SCSI drive, you should either build a new kernel, which
includes support directly for your SCSI card, or you should make sure your
system is set to automatically load a kernel module for your drive. In the
case of our Adaptec 2930 card, we only needed to add one line to our
/etc/conf.modules file, which says:

alias scsi_hostadapter aic7xxx

If your CD-R drive is attached to the same adapter as one of your hard
disks, then most likely this is already set up and functioning correctly.


Compiling Your Kernel

The easiest way to compile your kernel is to go to the kernel source
directory (in Red Hat this is always /usr/src/linux) and run the following
commands:

make dep (This builds the dependencies between objects)

make clean (This cleans out any old compiled objects that might be left from
before)

make bzImage (This builds a compressed kernel image)

cd arch/i386/boot

mv /boot/vmlinuz /boot/vmlinuz.old (Save a copy of your old kernel)

cp bzImage /boot/vmlinuz (Install the new boot image)

/sbin/lilo (Run lilo to set up the boot loader for the new image)


If you're really worried about corrupting your system, you can install your
test kernel to a floppy disk instead of your hard disk by doing a make
bzdisk rather than make bzImage.

Most likely, you'll also want to compile your modules--if in fact you made
any new modules--which you can do by executing the following commands on the
next page:

make modules

make install-modules

Once your kernel is built and installed, you're now ready to reboot and make
sure your CD-R drive is working. Remember that if you have an IDE drive, you
have already configured it to look like a SCSI drive. So from now on, your
drive that used to be called (for example) /dev/hdb will now be called
something more like /dev/scd0. Somewhere in your boot message you should see
some lines that look something like this:

Feb 7 15:32:53 localhost kernel: scsi0 : SCSI host adapter emulation for IDE
ATAPI devices

Feb 7 15:32:53 localhost kernel: scsi : 1 host.

Feb 7 15:32:53 localhost kernel: Vendor: Memorex Model: CRW-1622 Rev: D4.0

Feb 7 15:32:53 localhost kernel: Type: CD-ROM ANSI SCSI revision: 02

Feb 7 15:32:53 localhost kernel: Detected scsi CD-ROM sr0 at scsi0, channel
0, id 0, lun 0

Feb 7 15:32:53 localhost kernel: scsi : detected 1 SCSI cdroms total.

Feb 7 15:32:53 localhost kernel: sr0: scsi3-mmc drive: 2x/6x writer cd/rw
xa/form2 cdda tray

Feb 7 15:32:53 localhost kernel: Uniform CD-ROM driver Revision: 2.56

These lines show you the emulation of your IDE drive as a SCSI device. Note
that this drive is now known as sr0, which is the same as scd0. Sr0 is the
old name used for SCSI CD-ROMs, and it is the name the kernel prints out. To
tidy up, you may want to remove your old /dev/cdrom link and re-link it to
/dev/scd0.

Burn, Baby, Burn!

cdrecord and mkisofs

Many software packages are available now for burning CD-R discs in Linux.
Most of them use Jorg Schilling's cdrecord utility to actually burn the CD.
One of the first packages you should obtain is the cdrecord package, which
also includes a few other low-level utilities for building CDs. In addition
to the basic cdrecord utility, it includes cdda2wav, which allows you to
extract a WAV file from an audio CD, and the mkisofs utility, which allows
you to build an Iso9660 image from a set of files on your hard drive.
Mkisofs is essential because CDs are not burned with a normal file system
like the ones used in Linux or Windows. CDs contain a special file system
known as Iso9660, which is standard. Mkisofs will build an Iso9660 file
system image, either as a straight image or incorporating a number of
different extensions, such as the RockRidge or Joliet extensions. Cdrecord,
on the other hand, is used to take the Iso image and burn it on a blank CD.

Current Red Hat distributions include fairly recent versions of these
utilities, though you must be sure that the cdrecord rpm is installed on
your system. Note, however, that some of the GUI front-ends to be discussed
later require very recent versions of cdrecord, so you may need to download
a new release and compile it. Check this month's disc for a recent version,
too.

This is a very flexible command-line package. For the moment, let's explore
some of the commands you can use to burn a CD with cdrecord and mkisofs. You
must first find out the SCSI bus, ID, and LUN addresses by running cdrecord
in scanbus mode, which will scan all the SCSI devices on your system. You
perform this by typing:

cdrecord -scanbus

which will return a list of your SCSI devices and where they are located. On
our system, this returns:

Cdrecord 1.8 (i686-pc-linux-gnu) Copyright (C) 1995-2000 J�rg Schilling

Using libscg version 'schily-0.1'
scsibus0:
0,0,0 0) 'ARCHIVE' 'Python 28388-XXX' '5.45' Removable Tape
0,1,0 1) *
0,2,0 2) *
0,3,0 3) *
0,4,0 4) 'PLEXTOR' 'CD-R PX-W124TS' '1.01' Removable CD-ROM
0,5,0 5) *
0,6,0 6) *
0,7,0 7) *
scsibus1:
1,0,0 100) 'I/OMAGIC' ' 48SB CD-ROM ' 'M2.8' Removable CD-ROM
1,1,0 101) *
1,2,0 102) *
1,3,0 103) *
1,4,0 104) *
1,5,0 105) *
1,6,0 106) *
1,7,0 107) *

From this you can see that the Plextor CD burner is at address 0,4,0. Our CD
reader is simulated to be a SCSI drive at address 1,0,0. You will need these
numbers later to tell cdrecord how to address the CD burner. Next, we'll use
mkisofs to create an ISO file system image, and then cdrecord to burn the
image to a CD. For example, if you had a set of files in the directory
/home/shanson/upgrades, you could easily make a copy of that directory tree
onto a CD-ROM by using a command set similar to that shown below:

mkisofs -r -o /home/shanson/cd_upgrade_image /home/shanson/upgrades
cdrecord -v speed=2 dev=0,0,0 -data /home/shanson/cd_upgrade_image

In this example, you would've taken the directory /home/shanson/upgrades and
built an Iso9660 CD image in a file called /home/shanson/cd_upgrade_image.
This is what the mkisofs command does, and the -r option sets all the
permissions of the files on the CD to be publicly readable, also enabling
the RockRidge extensions. The second command line takes the image you
created and writes it out to the CD-ROM drive. In this case, it writes it
out to the device that is at SCSI bus 0, device 0, lun 0 (our /dev/scd0
drive) and does it at a 2X speed. The data is taken from the directory
/home/shanson/cd_upgrade_image. The -data option tells the command to write
the CD as a data CD. Notice, in this example, that the SCSI bus, device, and
LUN numbers reference the drive.

Burning an audio CD is also fairly simple with these commands. If you want
to copy some audio tracks from an existing CD, then you will first need to
rip the audio from a CD with the cdda2wav program. An example of this would
be
cdda2wav -D 0,4,0 -B /tmp/data

This example will read in all the tracks on your audio CD and write them out
individually to files in the /tmp directory. They'll be written by default
as .wav files. After writing out the files to your hard disk, you can burn a
CD from them by using the cdrecord program again. The syntax for using it to
write audio CDs is very similar to writing data CDs. An example would be:

cdrecord -v speed=8 dev=0,4,0 -audio /tmp/data*.wav

which will take all the audio files you wrote out previously and use them to
burn a new CD of your audio. Note that cdrecord and mkisofs are both complex
programs with many options. Read the manual pages for details on how to use
them.

GUI Front-Ends

Okay, now that you know how the underlying software works, let's take a look
at some of the fancier GUI front ends. All these programs use cdrecord and
other related utilities, but they make them easier to use by providing
simple front ends. This way you don't have to remember all those arcane
program options and can work from a much simpler GUI interface. All these
programs have their own strengths and weaknesses, and you may want to load
up several of them to try them out. They're all free, and almost all worked
well when we tested them.


KreateCD

One of the newer software packages available is KreateCD, which is a new
KDE-compliant package for CD burning. KreateCD basically does the job, and
can create data CDs, Audio CDs, and multi-session CDs. The data-burning
functions of KreateCD are fine, although we found the user interface a
little confusing. However, the audio disc creation with this package was
very useful, and has some features that none of the other packages have.
Particularly, if you like to burn custom CDs with tracks taken from various
CDs, this package has the capability of normalizing the volume on all the
tracks by setting them all to the volume of the track with the maximum
volume. This feature can be turned on and off, so we found it to be very
nice for assembling custom CDs for on-the-road listening. It's also easy to
listen to the tracks you've ripped from your CDs, and make manual
adjustments in volume and balance before doing the actual burning.


Xcdroast

This has become one of the more popular front-end packages for burning Linux
CDs. Of all packages available, it has one of the least confusing and most
versatile GUIs. There are actually two different versions of Xcdroast
commonly in use. The older version, 0.96, is powerful, but not portable to
non-Linux versions of UNIX. 0.96 is the more commonly used version, and it
does many different things well. Xcdroast can be used to master most kinds
of CDs, as well as duplicating data and audio discs.

The new development version of Xcdroast, version 0.98, is more portable and
will do more--when its finished. Unfortunately, at the moment, it is not as
versatile as the old version, and will not burn audio CDs on-the-fly.
Version 0.98 is written using the GTK widget set and is nicer looking. When
completed, it will be one of the easiest to use and most powerful graphical
front-ends for burning CDs.


Gcombust

Gcombust is a GNOME interface CD-burning application. Because it is tightly
integrated into the GNOME user interface, it is easy to use and allows you
to, for example, drag and drop files from the file manager onto its canvas,
rather than having to select them by name or though an integrated browser.
Gcombust has a lot of features, and we recommend it highly, particularly if
you're using the GNOME desktop.


Special Software: Disc-cover

Disc-cover is a wonderful program if you make a lot of copies of audio CDs.
(We won't lecture you on �stealing� music.) Disc-cover reads in the timings
for your audio CDs and sends the information off to the CDDB service, which
has a large CD database. Your CD will almost always be in that database, and
Disc-cover will write out a Postscript file to create jewel-case inserts,
including a list of the songs. You can even insert pictures in the cover and
write out your covers in a number of different formats. The program uses a
number of different Perl modules that you're not likely to have installed on
your system. It took us a while to collect all of them and get them
installed on our system. However, once you have them, you have the same kind
of capabilities you'd have with the latest cover-making software in Windows.


Back to the Index