Writing CDs with Linux
In this article we describe how you can write CDs under Linux.
Perhaps you have read Katja's article A whole new world in our
last issue and went on the tour with Tux. And now you have a
lot of "sights" and "sounds" that you want to bring home and
wonder how you can do this. Burning everything on a CD is a
good solution and in this article we are going to tell you how
you can do just that.
What you need
Of course Linux must be up and running on your computer and
you need a CD burner to do the job.
If you have a SCSI CD burner chances are very good that your
burner is immediately recognized by the kernel. You only have
to check whether your SCSI hostadapter is supported by Linux
(see the hardware database
for this). All SCSI CD writers will work under Linux.
For an ATAPI/IDE burner you have to configure SCSI emulation to
make your burner look like
a SCSI device even though the
hardware is physically connected via the IDE bus. How to do
this is e.g described in the README.atapi
file from xcdroast and we also recommend you to read the CD
Writing HOWTO at
For USB burners see the USB-CD Writer HOWTO at mobilix.org/linux_usb_cd.html.
As we both only have experience with SCSI burners we could
only repeat what we have read there.
Software to burn CDs:
For burning CDs you need the following programs:
All three are included in the cdrtools package you can download
- cdrecord: this is the program that actually communicates
with your CD writer.
- mkisofs: you need it for making data CDs. It is used to
generate a file system image for the CD called ISO
- cdda2wav: this is needed to read digital audio data from
With these tools you can already burn your CDs using the
command line. But if you want a nicer and friendlier graphical
user interface you need one of the frontends in addition. There
are a lot of frontends available but in this article we will
only talk about xcdroast (http://www.xcdroast.org) and
koncd (http://www.koncd.org/). xcdroast
seems to be the frontend with the most possibilities and we like
koncd because it is really very easy to use.
In many cases xcdroast will already be installed on your
computer but at least with the RedHat distribution it is
compiled with the pam-library which means it will always ask
you for the root password if you want to burn CDs and you
probably don't want to give the root password to all users who
want to burn CDs. A second drawback is that it will not allow
you to start the program remote over a network. Therefore it is
better to download the latest version from
http://www.xcdroast.org. This should be straight forward as
there are pre-compiled packages for most of the common
koncd can be downloaded from www.koncd.org. Recent versions of
koncd rely on new QT/KDE features. If you don't want to spend
time updating your QT and KDE libraries you can use an older
version of koncd. For this article we have used koncd-0.7.5
running under redhat 7.1.
Burning CDs as a normal (non-root) user
To burn CDs you first of all must have write permissions to the
/dev/sg* devices which are used for the communication with the
hardware. But cdrecord also uses some realtime extensions to
avoid buffer underruns during the writing process that require
root permissions as well. The best solution is therefore to use
SUID on cdrecord and cdda2wav. Uhh? SUID? Don't worry. You can
read Guido's article on file permissions if you
want to know exactly what it is but for the moment it is
sufficient if you type in the following two commands and then
forget about it again :-)
chmod 4111 /usr/bin/cdrecord
Be aware that this could be a potential security risk but it is
definitively less of a security risk than telling everybody who
wants to burn a CD what the root password is.
chmod 4111 /usr/bin/cdda2wav
Now you can test if your CD writer is recognized correctly.
If everything is alright then you should see something
0,6,0 6) 'PLEXTOR ' 'CD-ROM PX-W8220T ' '1.03' Removable
The numbers and the description may be different dependent on
your hardware setup.
Alternatively you can also click on the SETUP button of
xcdroast or koncd and check there if your burner is recognized
So let's now finally start burning a CD.
General notes on burning CDs
There are four necessary steps to write CDs:
CDs generally need to be written in "one go" and the data flow
needn't be disturbed during the writing process. Thanks to the
realtime extensions buffer underruns who lead to faulty CDs are
only a problem of windows users. With Linux you don't really
need "burn proof". There is a special buffer called FIFO inside
the CD writer to compensate for small disturbances which is
usally enough to avoid burn failures under Linux. Nevertheless
you should be cautious and don't do things that need too much
CPU power. You can browse the web, compile software, ... but
deleting a large file can be a problem and maybe is enough to
disturb the process which then results in a faulty CD.
- You have to select the data/music you want to burn on
- You have to set some options for the CD that is going to
be burned. For example when you want to burn an audio CD you
have to choose between TAO and DAO mode or for a data CD you
have to set some options for the filesystem.
- You must create an image directory with the files you
want to burn on CD.
If you only want to duplicate another CD completely you will
"write on the fly" otherwise you have
to create an image on harddisk first.
An image directory is a temporary storage place for the data
that will be written to the CD. For audio CDs these are index
files and the wav files containing the music and for data CDs
this is a big file called ISO image.
- You actually burn the CD.
If you are concerned about buffer underruns you can use the
simulation write (dummy write) option to first test if the CD
writing would work before actually burning it. There the
burning process is tested with real data but the laser inside
the CD writer is turned off. It is always better to run a test
first than to have to do it all over again.
The fact that you usually have to burn in "one go" which means that if you
have forgotten something, even if it is only a single small
file you have to burn the CD again. There is the
possibility of multisession where you can add something later
but we won't talk about it here because with multisession you can't
read the CD on many CD writers as long as it is not ready and
as the prize of one CD is
so low we never had a reason to use it.
When you start koncd or xcdroast you will recognize that both
of them have a setup button. Here you can find out if your
burner is recognized correctly and set general options.
look at the setup of xcdroast and koncd:
The first time you will get a pop up window saying that
root should start the program first and configure it so
that not every single user has to do it all over again.
- Device Scan: here you will see all devices connected
to your SCSI bus.
- CD settings: here you can select your CD burner and
the device where the data/music should be read from.
For "CD writer mode" you have to give the right driver
but usually "autodetect" should be okay.
CD Writer FIFO Buffer size: this depends on your
hardware. You have to look at the manual of your writer
for its size. Common values for that buffer are 4MB or
As a CD must be written without an interruption in the
data flow (due to the design of CD burners) there is a
buffer (=FIFO) which avoids that just because of small
disturbances the burning process will fail.
- HD settings: Here you need to specify a temporary
storage directory for the ISO image. There should be more
than 800MB of free space available (you can check your
free space with the shell command df -k /the/directory or
by using a file manager).
- Audio: this is only of interest if you want
xcdroast to play the songs, it doesn't have any
influence on the burning process. DSP stands for
digital signal processor and it is the part that will
send sound to the loudspeaker.
- Network: for a lot of CDs there are information
about their titles available from a database in the
internet. When burning your CD you can ask for this
information which can save you a lot of typing work
if you want.
- Logging: to create a log file
- Internationalization: here you can choose your
language and everything will be in your chosen
- Options: here you can e.g. set if you will get tips
on the options buttons when you go over them with your
mouse pointer. Especially if you don't know the program
very well we recommend to have these tips.
- Users: This panel appears only if you are logged in
as root. Here you can define what normal users are
allowed to do.
You see the devices that koncd
automatically detected in a selection box. You can tell the
program to which writer it should write when burning (this
should be your CD burner) and from where it should read CDs.
This could be your CD ROM or if you only have this one CD
burner then this can be used for reading and writing CDs.
You can also select "burn proof" here if it is supported by
your CD burner. Burn proof slows down the speed of your
writer when the FIFO (see above) is almost empty.
(Pure) music (audio) CDs
Here you should think about the format a little bit first. If
the song is from another CD there is no problem. You can just
go on and copy it. But otherwise you should notice that
cdrecord recognizes au and wav files and converts them
automatically to the right format to play it on your CD player
but for other formats you need to convert them to wav first if
you later don't want to hear only noise on your CD. To convert
a file from mp3 to wav you can do the following on the command
mpg123 -w /tmp/song.wav song.mp3
This allows you to make normal audio CDs from mp3 music. It
takes more space but can be played in almost every CD
When finally burning the CD you can choose whether you want
the copy to be in TAO or DAO mode. In TAO mode you will have 2
seconds of a pause between each song while you don't have that
in DAO mode which makes it the mode of choice for live music
recordings. TAO= Track at Once and DAO= Disk at Once.
You can copy a CD completely or mix songs from different CDs,
or other sound files e.g. downloaded from the internet.
Let's first see how you can copy a CD without changes:
Select "Duplicate CD".
You get a menu on the left side where you can see:
CD/Image Info, Read Tracks, Verify CD, Play
We don't know why these menu entries are available. They
don't make sense if you just want to duplicate a CD. At
least in the version used for this article
(xcdroast-0.98alpha9) xcdroast only allows you to do a
"write on the fly" for which you only need the "Write CD"
menu. Therefore go directly to "Write CD".
- On top you again have to specify the device to read
from and its speed. Next select the CD burner and its
speed. The speed of the reader should be a bit higher
than the writing speed (to avoid buffer underruns).
- Left you see "CD to write":
This is just for your information. You have no other
choice than "write on the fly".
- Right you see "write parameters":
CD R/RW type: here you have to specify how many minutes
will fit on the CD you are burning the music onto
and then you have to choose between TAO or DAO mode (see
You can then decide to make a simulation write first
(see above) and if you want the CD to be ejected after the
burning is finished. "Pad tracks" is not important when
With "Blank CD-RW" you can delete rewritable CDs and
finally with "WRITE CD" you can burn your CD. That's
Choose "Copy CD".
On top you can delete the content of a rewritable CD and set
the burning speed. Under "options" you don't need to select
anything. Press "START" and the burning begins.
Let's now look what you have to do if you want to burn a CD
with music from various places:
Now you have to select "Create CD".
Let's look at the menu:
- CD/Image info:
On the left side you see the content of the CD that is
read from. On the right side you see the content of the
image directory if you have anything in there. There is
nothing to do here. Go straight to "Read Tracks"
- Read Tracks:
On top you have to choose the device where the music
should be read from and the image directory. Now in this
case the tracks will be written as individual wav files
and not as a single big image file. For music CDs you
should not go too high in speed because audio CDs are
only specified to be read at "1 x" speed and a higher
speed increases the occurence of bit errors which reduces
the quality. However a speed of "4 x" or "8 x" should be
To read the music tracks to the image directory select
the tracks you want to copy and then press READ SELECTED
- Verify CD:
If you press the VERIFY button it is verified that the
reading of the music tracks was done without bit
- Play Audio-Tracks:
With this you can play the songs as they are in the
image directory. To select a song to be played you need
to double click on it.
- Master tracks:
This is only for data CDs. Ignore it for the
- Delete Tracks:
Here you can see how much space you have already used
and how much is still left. And you can delete all or
some tracks from the image directory according to your
- Write Tracks:
Here you first need to go to the second panel "Layout
tracks". On the right you will see the content of the
image directory. Select the tracks and press "add" to
copy them over to the left panel for writing tracks. Go
back to the "write tracks" panel. Here you find the same
options that were already explained under "Duplicate CD".
But now you have to select the option "PAD tracks". This is
to ensure that all .wav's are properly terminated on
sector boundaries. The Audio CD format requires that
all wav files are a multiple of 2352 Bytes long. "PAD
tracks" adds some zero-bytes to ensure the correct
length. Press "WRITE CD" to burn the CD.
Choose "audio CD". The version used for this article (0.7.5)
does not yet have the possibility to read individual audio
tracks from another audio CD. But you can select a number of wav
files somewhere on your harddisk and write them as audio
tracks to the CD. Click on "Add track" and add several wav
files to the list of selected tracks. Under "options" select
"Use padding" and then click on "start" to burn your CD.
(Pure) Data CDs
For data CDs you need a filesystem or as is often said the CD
must be formatted. You have to choose which filesystem you
want. This choice will depend on which operating system(s) you
want to be able to read the data. The ISO-9660 standard which
describes the CD filesystem for example does not allow long
file names. Therefore extensions have been made for this
standard. For Linux and Unix RockRidge extensions are used,
Microsoft uses Joliet extensions.With the RockRidge format you
can also have permissions etc. as you already know it from your
The recommended solution is to use RockRidge and Joliet
extensions on the same CD.
If you just want to copy a CD from another existing CD you
don't have to worry about that because then the CD already has
a filesystem and this is copied as well.
Choose "Duplicate CD"
and then do everything as described above. Just go to "WRITE
Choose "Copy CD" ( see above).
If you want to copy data from your hard disk :
Choose "Create CD" and then "Master Tracks" from the menu
on the left.
Now go to "Write Tracks":
- Under "Master source" you select the directories that
you want to write to your CD. You can also choose the
paths and names these directories should have on CD (use
the "redirect" button on the left side to do this).
- ISO 9660 options:
You can choose one of the predefined image types:
just use RockRidge + Joliet if you want your CD to be
readable for Linux and Window computers
- Under boot options you can create bootable CDs but
this is beyond the scope of this article. If you want a
bootable CD then we recommend you to use one of the
pre-build ISO images (see the references at the end of
- Create session/image: This is the most important
panel. Here you can now create an ISO image of the files
selected in the first panel. Press the button "master
image to file" for that.
Always choose "fixation" (or better: don't choose "Do
not fixate after write") unless you want to do
mulitsession, otherwise if you don't choose fixation no
Toc (= Table of Contents) is made and your CD won't be
readable for many CD players.
Here you use the image that you created under the panel
"Master tracks". Go to the panel
"Layout tracks", select your image and press "add". Then go
back to the panel "Write tracks" and press the button
"write tracks" at the bottom. Now your CD is burned.
Copy all the files that you want to write to CD into one
directory (using either the shell command cp or a file
Open koncd and choose "Master CD".
Under "data" you give the source directory to where you
copied the files. Now you have several possibilities to
create the CD. We suggest to create an ISO image first and
then write the image to your CD. Under Data -> "image
file" enter the name for the image file that will be created.
The version used for this article required that the file
would already exist. Therefore create an empty file called
"image" with the shell command "touch image".
Go to "options" and click on "Create CD image", press
"calculate size" on the right and then "start".
Once the image is created you click on the option "Write CD"
and unselect "Create CD-image". Now the CD writer will burn
the CD for you.
Backup of your home directory
Basically you can backup everything on CD with the method
described under "pure data CDs".
If the data in your home directory is too big to fit onto one
CD then you need to select individual sub-directories and write
them to a different CD.
Tips and Tricks:
It can be useful to check if the ISO image is correct
before finally burning it. To do this you can mount the ISO
image as if it was a real CD:
Change to root: su -
... and burn the image to your CD.
Create an empty directory (known as mount point): mkdir
Mount the ISO image (connect the ISO image to the
mount -o loop -t iso9660 Image.iso /tmp/mycd
Now you can use the command "ls" to inspect the CD image: ls
If it looks ok then unmount it: umount /tmp/mycd
Command line tools
Above we have discussed two graphical frontends to burn CDs but
you can also burn CDs using only the command line. If
you look at the man page of cdrecord you will see that there
are hundreds of options, uuuhh... don't be scared. It's much
easier than it looks at first. Download the two perl scripts
cdrecordeasy and mkisofseasy.
They are included in the package easycdscripts (download
Unpack them with the command
tar zxvf easycdscripts-0.1.tar.gz
Now run the command cdrecord -scanbus. Look at the line where
you see your CD burner and remember the numbers that you see at
the beginning. It should be something like 0,4,0 or 0,6,0
Edit the file cdrecordeasy by entering this number behind the
line that says $dev=... You will find it somewhere at the
Now the installation of our two little scripts is finished.
Creating a data CD is now very easy:
That's it. Much easier than it looked at the beginning, isn't
- Copy all the files that you want to have on the CD into
one directory (e.g ~/cdrom). Harddisks are very big and cheap
these days and it should be no problem to copy a few hundred
- Run the command: mkisofseasy ~/image.iso ~/cdrom
This will create an ISO image of all the files in the
- Burn the CD by running the command: cdrecordeasy
Have fun with your CDs!
Talkback form for this article
Every article has its own talkback page. On this page you can submit a comment or look at comments from other readers:
2001-12-31, generated by lfparser version 2.23