Contents
- Introduction
- What is a CD burner?
- Buying a CD Burner
- Setting up your CD burner
- Creating a data CD
- Creating a music CD
- Using a GUI
- Advanced topics
- Warnings
- Summary of command lines
- References
If you want to burn CDs under Linux, then read the
CD-Writing HOWTO. If you
still have questions, then move on to the
CD recordable FAQ, a comprehensive
list of common questions. I shall refer to these as the "HOWTO" and the "FAQ"
respectively. This document is meant to be a summary of some of the
information in the HOWTO and FAQ, a quick reference so that you don't have to
go to the full document all the time, and some notes on other useful hints and
tips. A lot of this information I have simply copied straight from the
relevant HOWTOs.
CD Writers
CD-Writers have a more powerful laser than normal CD readers. This laser is
capable of burning pits inside special CD-Recordables (CD-R discs).
CD Writers can read data and audio discs just like a regular CD ROM drive.
CD Re-Writers (CD-RW)
A CD Re-Writer is essentially a CD Writer with a more powerful laser. They
can record CD-Rs exactly as a CD Writer and they can also handle CD-RW discs.
CD-RW discs are different to CD-Rs. Instead of burning pits in the disc, the
laser causes a phase change in the CD medium. The change may be reversed to
erase the data. However most CD-RW discs are only able to be read on another
CD Re-Writer because they need a more powerful laser to read them.
SCSI vs IDE/ATAPI
- SCSI: "Small Computer Systems Interface"
- ATA: "Attachment Adapter"
- IDE: "Integrated Drive Electronics" (includes ATA)
- ATAPI: "ATA Packet Interface"
Roughly speaking SCSI and IDE are the two main ways for your external devices
(hard disc, CD-ROM etc.) to talk to your motherboard. SCSI is typically
faster and easier to use, while IDE/ATAPI is cheaper. All CD burners run from
SCSI commands, so when you install the CD writer you must either have a SCSI
one, or install the ATAPI-SCSI emulation driver. For more information there
are some notes included with the
cdrecord documentation.
Internal vs External
An external drive is potentially better because you have the
option of moving it between machines, but unless you know lots of
people with SCSI cards, or have a parallel port burner, then this
isn't much of an advantage. It used to be better to get an external
drive because of the heat, but the technology has improved to the
point where that isn't necessary.
SCSI vs IDE vs parallel vs USB
USB CD-writers are currently not supported at all. Apart from that
you can safely assume that most newer IDE/ATAPI- and SCSI-writers
work under Linux. It is possible to connect drives via the parallel
port, but I know nothing about it. Read
http://www.torque.net/parport/parscsi.html to learn more about
this option.
Which is better? SCSI is probably easier to set-up, used to be
less prone to buffer underruns and produced higher quality audio
discs (IDE has improved). It also gives you the option of
doing a direct disc-to-disc copy. However it is more expensive.
What speed?
As fast as you can afford. A driver rated at "1x" will write the
disc at the normal speed; i.e. it will take 74 minutes to write a
full disc. One rated at "2x" will take half that time and so on.
Waiting over an hour only to find you have burned a coaster is quite
off-putting. Fifteen minutes (at 4x), on the other hand, is
bearable.
Which writer?
The FAQ has a very good list of
CD-Writers and their merits, including a summary of the "best" drives. You
must make sure you get a supported drive - see the
HOWTO for a summary or go
here for a
complete list.
For a full description see the HOWTO.
SCSI
If your system isn't SCSI, then you need a SCSI card as well. I have a
TEKRAM D-390-UW which is not too expensive (i.e. a third the price of the
equivalent Adaptec) and performs well. The basic steps are:
- Plug in the hardware (make sure your cable is terminated).
- Set up the kernel module for your card. There used to be a list of
which driver corresponded to each card, but I can't find it. I have
a line in /etc/conf.modules that reads
alias scsi_hostadapter ncr53c8xx which tells the
kernal to load the ncr53c8xx driver for my card.
- Find out where on your SCSI bus your drive is. You can run, for
example,
cdrecord -scanbus
and I get lines like:
0,1,0 1) 'TEAC ' 'CD-R55S ' '1.0L' Removable CD-ROM
This says my drive is on bus 0, with SCSI id 1 and Logical
Unit Number (LUN) 0. You need this information for later.
IDE
- Plugging in the hardware is straightforward; just put it in
your drive cage and plug in the cable and power supply.
- To use an IDE writer you need the ide-scsi compatibility
kernel module. You have to be careful to set this up so that it
only accesses the drives you want to be accessed as SCSI drives, but
it can be done. Also, please note that when you have this module
running it may still be used to access your existing CD ROM drive.
The difference is that you access it via the SCSI devices
/dev/sg* or /dev/scd*, rather than the IDE
devices /dev/hd*. For more information see
cdrecord/README.ATAPI
- Once the ide-scsi driver is installed, proceed as for SCSI.
Getting the software
The main software components you need are
- cdrecord
- A command line tool for recording CDs.
- cdda2wav
- A command line tool for reading audio data from CDs.
It is included in the cdrecord package.
- mkisofs
- A command line tool for creating the filesystem images needed
to record data CDs. This is also included with cdrecord, and has
merged with mkhybrid for making hybrid filesystems.
- cdparanoia
- A command line tool for copying audio data from audio CDs. This
will perform "paranoid" copying - which includes scratch repair,
so-called jitter correction and more.
- mpg123
- If you want to record mpegs to CD this utility will convert mp3
files to the correct format (as well as play them...).
- sox
- A command line utility to convert between various audio formats.
- play
- A frontend for sox that lets you play any of the formats that
sox understands - usually included with sox.
These are the basic command line utilities that you need. Most of the GUIs
use one or more of these to provide their functionality. You can do most of
what you need with these tools, but for trickier features you either have to
understand what you are doing very well, or use one of the GUIs. More about
them later.
Creating the filesystem image
You could write your file system directly to the CD and make a perfectly good
disc. However you would only be able to read it under Linux, and more than
likely your CD-ROM is not expecting to read an ext2fs filesystem on a CD.
Instead you use a tool such as mkisofs. This will take a snapshot
of a given directory tree and create a binary image that corresponds to an
iso9660 or HFS filesystem.
mkisofs has a very long list of complicated options and I always
use xcdroast to create my disc images. However if you
want to include all files
from a single directory, /home for example, then you can simply
type:
mkisofs -r -o cd_image.raw /home
and this will generate the file cd_image.raw containing your data.
The maximum size a data image can be is about 650Mb. The -r
option enables the Rock Ridge extensions to iso9660 for long filenames and also
sets all files to be readable so that anyone can read the disc. If you want
Rock Ridge without anonymity, then use -R - however if you try to
read the CD generated on another Linux system with different user id
numbers, then you will only be able to read it as root.
Testing the image
If you have loopback device support (on by default in most distributions), then
you can test your image by mounting it. To mount the file you have just created
on /mnt/tmp run
mount -t iso9660 -o ro,loop=/dev/loop0 cd_image.raw /mnt/tmp
You may then change to the directory /mnt/tmp and you should see
a copy of your /home directory sitting there. When you are
finished move out of the directory and type umount /mnt/tmp to
unmount it.
Burning your first CD
If you haven't already tried, it's a good time for the command
cdrecord -scanbus
(see above). This will tell you where on your SCSI bus the burner is. I get:
0,1,0 1) 'TEAC ' 'CD-R55S ' '1.0L' Removable CD-ROM
and so I use the 0,1,0 for the dev argument to
cdrecord.
If you have never burnt a CD before or if your system is
loaded, then you should always do a test run by calling cdrecord in "dummy"
mode. In this mode cdrecord runs exactly as normal, except that it doesn't
turn on the laser. That way you can check to see if you are likely to suffer
from buffer underrun, i.e. your computer cannot get the data to the burner fast
enough. Test cdrecord in dummy mode with:
cdrecord -v -dummy speed=4 dev=0,1,0 -data cd_image.raw
Record the image with:
cdrecord -v speed=4 dev=0,1,0 -data cd_image.raw
Replace the speed=4 argument with the speed of your burner.
Testing the CD
The quickest way to test the CD is to mount it and look at what's there.
If your CD writer is /dev/scd0, then you can mount it at
/mnt/cdrom with
mount -t iso9660 /dev/scd0 /mnt/cdrom
Now, ls /mnt/cdrom should give you a listing of your files.
If you want a more detailed check, then get
star by the author of
cdrecord. This is "s-tar" for "SCSI Tape Archiver", a version of tar written
specifically for SCSI devices. It has a long list of features for verification
and
is quicker and easier than using diff -r. If you used mkisofs with
-r, then you can check the filesystem with
(cd /home; star -cPM .)|(cd /mnt/cdrom; star -diff -v \
diffopts=\!times,\!perm,\!uid,\!gid,\!uname,\!gname)
otherwise you can just use
(cd /home; star -cPM .)|(cd /mnt/cdrom; star -diff -v diffopts=\!times)
For more information see
cdrecord/README.verify.
Getting the audio data from a disc
The encoding for audio discs is completely different to that for data discs.
The two main programs for getting audio data from a CD onto your hard disc in a
useable form are cdda2wav written by the author of
cdrecord, and cdparanoia. The first is much faster
and produces .wav files which cdrecord understands, while the
second can produce much higher quality copies either as raw data (which cdrecord
understands) or as .wav files. I always use cdparanoia. Some
sample command lines follow.
Get cdparanoia to read the disk in /dev/scd1 and list its table of
contents:
cdparanoia -d /dev/scd1 -Qv
Read the whole of track n and write the data to the file
track_n.cdr:
cdparanoia -d /dev/scd1 n track_n.cdr
Read the whole disk a track at a time, putting each track into a separate file
track#.cdr:
cdparanoia -v -d /dev/scd1 -B 1- cdr
Warning: CD readers, like computers, are inconsistent in
the way they return the data, big or little endian. Read the documentation for
full details, but here is a quick test. Read a track from your CD using
cdparanoia and then try to play it with play track01.cdr. If all
you hear is hissing, then the data is coming out in the wrong byte order.
To force cdparanoia to return big endian data use the -R flag, and
to force little endian use the -r flag. One of these should produce
a track that play will play. If you burn the disc and all you hear
is hissing, then this failed and you still have the wrong byte order. Try it
again using the -swab flag with cdrecord. I need to force big
endian with my setup, so my commands look like:
cdparanoia -v -d /dev/scd0 -R -B 1- cdr
and then I don't need to use the -swab flag with cdrecord.
Using mp3s for your audio data
MP3 files are just another way of encoding audio data. They can be converted to
a form suitable for recording with mpg123, which is also an
mp3 player. If you have the mp3 files you want to convert in the current
directory, then this will do the trick:
for file in *.mp3
do
mpg123 --cdr - $file > $file.cdr
done
This will convert files like my_music.mp3 and produce
my_music.mp3.cdr. I'm sure you can come up with something more
sophisticated, but this shows how to use mpg123.
Other audio formats
If you have audio files in different formats, then you can use
sox to convert them to .wav or .cdr
files. sox understands a large variety of audio formats; see the documentation
for a full list. If you are interested in the format of various audio files,
then you will be interested in the
Audio File Format FAQ
which is maintained by the current maintainer of sox.
Recording an audio CD
To record audio files track01.cdr track02.cdr ... in that order
you can use:
cdrecord -v speed=4 dev=0,1,0 -audio track*.cdr
Note that this relies on the alpha-numeric ordering of the shell's wildcard
expansion of "track*.cdr". It doesn't hurt to do
/bin/ls track*.cdr first to check that the files come out in the
correct order.
The two graphical interfaces I have experience with are
X-CD-Roast and gcdmaster. Some
tasks, particularly creating data images with mkisofs, are
sufficiently complicated that a GUI is very useful.
X-CD-Roast
This is written in tcl/tk and provides functionality for creating data and audio
disc images, and for recording and verifying the images. It is an independent
frontend for cdrecord and friends. The strong point of X-CD-Roast for me is that
it makes creating data images very simple. The only fault for me
is that it is very slow. It is currently coming to the end of a complete
re-write using the gtk libs. This makes it a lot faster and easier to use. It
also will have much more functionality - in particular it will make mixed mode
CDs, multisession CDs and so on. I would still recommend the current version
(xcdroast-0.96ex2-4), at least to start with, because there is little or no
documentation on how to use the newest alpha version (xcdroast-0.98alpha6).
Gcdmaster
Gcdmaster is also written with the gtk libraries. It is a frontend for
cdrdao and is intended primarily for creating audio CDs. It uses
the cdparanoia libraries for saving data from a CD, and cdrdao
for recording the data onto the CD. My main use for this is to record an audio
CD in "Disc At Once" made.
Disc At Once (DAO) vs Track At Once (TAO)
Most, if not all, CD writers force a two second gap between each track. So if
you write your audio tracks in TAO mode (this is the standard) then
you have to live with this gap. It can be a real pain if you have recorded a
live CD of your new band, but you want to put track marks in between the tracks
so that your CD player will see them. The other problem is that this can cause
clicks and pops (particularly with IDE writers) in the gap. The examples above
were for TAO mode.
Not all writers support DAO mode, but if yours does then you can record the disc
in one shot without the gaps. In order to put the track marks in you need to
write a table of contents (TOC) that describes where these occur. You can do all
this with gcdmaster (cdrecord has a flag for DAO, but no
explanation how to use it or specify the TOC etc.). Suppose your live recording
is in one huge file, image.bin, and you want to make the TOC. It
should be a separate file, image.toc, and look something like this:
CD_DA
// Track 1
TRACK AUDIO
NO COPY
NO PRE_EMPHASIS
TWO_CHANNEL_AUDIO
FILE "/images/cdr/image.bin" 0 04:12:59
// Track 2
TRACK AUDIO
NO COPY
NO PRE_EMPHASIS
TWO_CHANNEL_AUDIO
FILE "/images/cdr/image.bin" 04:12:59 03:29:22
START 00:01:73
The two times after the FILE argument are the start and length of
the track. The START argument after track2 (and higher) is the
length of the pre-gap. You can cut this to 00:00:00 for your live CD.
Gcdmaster will also read a complete CD into one large file, and write the TOC at
the same time.
Mixed Mode Cds: "CD-Plus"
Mixed mode CDs have both audio and data files on them; "CD Plus" refers to the
special case where the first session is audio tracks and the second session is a
data track. Many music CDs are CD plus discs. You don't notice anything special
if you put it in your CD player, but if you read it on your computer, then you
can also see the data track. The quick and dirty way to write these is just to
specify which tracks are audio and which are data:
cdrecord -v speed=4 dev=0,1,0 -audio track*.cdr -data image.raw
Note that most CD players can only read audio tracks in the first session, and
will see data tracks as gaps. For the "correct" way to write CD Plus discs read
cdrecord/README.cdplus and
for an explanation of "sessions" see the next section.
Multisession CDs
Instead of writing your CD all at once you may do it in several sessions. There
are several warnings that come with this, however:
- Most audio CD players can only read audio tracks written in the
first session.
- The data image for the second and subsequent sessions has to be
prepared with more care.
- The first session requires about 22Mb for writing additional data,
and subsequent sessions require about 14Mb, thus limiting the
number of sessions to a theoretical limit of around 44.
For more information on creating multi-session discs see
cdrecord/README.multi.
For an example, suppose you have the following directory structure in your
filesystem:
/home/
alice/
fred/
jane/
joe/
...
/var/www/
httpd/
...
and you want to make a disc that has directories
alice/
fred/
httpd/
jane/
joe/
...
and for some reason you want to write the stuff in /home in one
session, then the stuff in /var/www in the next session.
- Create the first data image:
mkisofs -r -o image1.raw /home
- Record it:
cdrecord -v speed=4 dev=0,1,0 -multi -data image1.raw
Note the flag to say that this is part of a multisession recording.
- Create the next data image (this is the tricky part):
- Find where the free space on the CD-R begins with
cdrecord -msinfo dev=0,1,0
The output should be two numbers separated by a comma e.g.:
0,204562
- Create the data image:
mkisofs -r -o image2.raw -C 0,204562 -M /dev/scd0
/var/www
where the argument of the -C
flag is the output of the previous command, and the
argument of the -M flag is a device that may be
used to mount the cd writer.
- Record the next data image:
cdrecord -v speed=4 dev=0,1,0 -multi -data image2.raw
- When you are finished writing images, either write the last one
without the
-multi flag, or finish with
cdrecord -fix
Some things to beware of when writing CDs.
- Make sure nothing is trying to access your CD drive other than
cdrecord. In particular make sure:
- any CD players are closed
- nothing like RedHat's "autorun" is running that periodically
checks to see if there is a CD in the device
- no other program has a lock on the device pointing to the cd
writer (e.g. because you ejected it without unmounting it)
Any attempts to access the CD device while recording will likely
cause the recording to fail
- If you have a slow or loaded system, then check that you won't
suffer from buffer underruns by first recording with the
-dummy flag. It is well named... If you do get buffer
underruns, then try closing some programs and use a slower speed.
Quitting X would also be a good idea, especially if you are short of
memory.
- Even if your system isn't loaded make sure no massive
cron jobs like slocate are going to run while
you're burning.
- If a music CD produces nothing but hissing, then is the data in the
right format, and in the correct "endian-ness"? You can try the
-R or -r flags for cdparanoia, and the
-swab flag to cdrecord (not all at once, though).
mkisofs
Create a data image of the contents of /directory using Rock-Ridge
extensions with anonymity
mkisofs -r -o image.raw /directory
Create a data image of the contents of /directory using Rock-Ridge
extensions, but preserving the original permissions and ownership
mkisofs -R -o image.raw /directory
Create a second data image based on a previous one:
mkisofs -r -o image2.raw -C 0,204562 -M /dev/scd0 /directory2
mount
Mount a data image on /mnt/tmp to test it
mount -t iso9660 -o ro,loop=/dev/loop0 image.raw /mnt/tmp
Mount the disc in your cd reader/writer corresponding to /dev/scd0
mount -t iso9660 /dev/scd0 /mnt/cdrom
Unmount the file/device/whatever that is mounted on /mnt/tmp
umount /mnt/tmp
cdparanoia
Get cdparanoia to read the disk in /dev/scd1 and list its table of
contents:
cdparanoia -d /dev/scd1 -Qv
Read the whole of track n and write the data to the file track_n.cdr
cdparanoia -d /dev/scd1 n track_n.cdr
Read the whole disk a track at a time, putting each track into a separate file
track#.cdr
cdparanoia -v -d /dev/scd1 -B 1- cdr
mpg123
Convert the mp3 file boring.mp3 to a raw audio file
mpg123 --cdr - boring.mp3 > boring.cdr
cdrecord
Test cdrecord in dummy mode
cdrecord -v -dummy speed=4 dev=0,1,0 -data image.raw
Record the image
cdrecord -v speed=4 dev=0,1,0 -data image.raw
Record audio files track01.cdr track02.cdr ... in that order
cdrecord -v speed=4 dev=0,1,0 -audio track*.cdr
Create a "mixed-mode" CD
cdrecord -v speed=4 dev=0,1,0 -audio track*.cdr -data image.raw
Create a multi-session CD
cdrecord -v speed=4 dev=0,1,0 -multi -data image1.raw
Finish (fixate) a CD only necessary if the last session was written with
-multi
cdrecord -fix
star
Test a disc written with Rock-Ridge extensions and anonymity whose contents
came from /directory
(cd /directory; star -cPM .)|(cd /mnt/cdrom; star -diff -v \
diffopts=\!times,\!perm,\!uid,\!gid,\!uname,\!gname)
Test a disc written with the original permissions and ownership
(cd /home; star -cPM .)|(cd /mnt/cdrom; star -diff -v diffopts=\!times)
The definitive HOWTO for CD recording. Read it locally in a
single document or in
parts. The newest version of the document can be
found at
http://www.guug.de/~winni/linux/cdr/html/. The author
has other useful documents and links at
http://www.guug.de/~winni/linux/.
The main homepage for cdrecord is at
http://www.fokus.gmd.de/research/cc/glone/employees/joerg.schilling/private/cdrecord.html. Cdrecord includes the programs cdda2wav,
mkisofs and mkhybrid.
There are many useful CD related links on this page. The documentation may be
read locally.
cdparanoia is a command line tool for copying audio data from audio CDs. This
will perform "paranoid" copying - which includes scratch repair,
so-called jitter correction and more.
The homepage:
http://www.xiph.org/paranoia/
The definitive CD FAQ. Read it locally or at its
home site, http://www.fadden.com/cdrfaq/
. There is also a single
page version (but it is huge).
Sox is almost the ultimate sound file format conversion utility. The homepage
is at
http://home.sprynet.com/~cbagwell/sox.html. The author also maintains the
Audio File Format FAQ.
mpg123 is an mp3 decoder/player - it claims to be the fastest available for
unix-type systems. The homepage is at
http://mpg123.org/.
A good general purpose frontend for cdrecord, cdparanoia and mkisofs. The
homepage is at
http://www.fh-muenchen.de/rz/xcdroast/
and the alpha version may be found at
http://www.fh-muenchen.de/home/ze/rz/services/projects/xcdroast/xcdr098/
Gcdmaster is a front end for cdrdao and may be used to create
discs in
"Disc-At-Once" mode. It also lets you edit the table of contents for a CD and
has several other useful features for audio CDs. Gcdmaster can be downloaded
from the cdrdao homepage at
http://cdrdao.sourceforge.net/ or from
rpmfind.net.
From the CD Writing HOWTO:
"If to smoke you turn I shall not cease to fiddle while you burn."
(Roman emperor Nero about burning his own classic-CDs, AD64. He
misunderstood it completely and burned Rome down.)
Copyright
Are you kidding? I copied most of this straight from the documents listed above.
It does come with a warning, though:
The author disclaims all warranties with regard to this
document, including all implied warranties of merchantability and
fitness for a certain purpose; in no event shall the author be liable
for any special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether in
an action of contract, negligence or other tortious action, arising
out of or in connection with the use of this document.
Short: read and use at your own risk. No money-back guarantee.
Robert Judd, Sunday 29 October 2000.