[LinuxFocus-icon]
Home  |  Map  |  Index  |  Search

News | Archives | Links | About LF
This document is available in: English  Castellano  ChineseGB  Deutsch  Francais  Nederlands  Portugues  Russian  Turkce  

convert to palmConvert to GutenPalm
or to PalmDoc

[Photo of the Authors]
by Katja and Guido Socher
<katja(at)linuxfocusorg, guido(at)linuxfocus.org>

About the authors:

Katja is the German editor of LinuxFocus. She likes Tux, film & photography and the sea. Her homepage can be found here.

Guido is a long time Linux fan and he likes Linux because it is designed by honest and open people. This is one of the reasons why we call it open source. His homepage is at linuxfocus.org/~guido.


Content:

 

Writing CDs with Linux

[Illustration]

Abstract:

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

Hardware setup:
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 linuxdoc.org
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:

  1. cdrecord: this is the program that actually communicates with your CD writer.
  2. mkisofs: you need it for making data CDs. It is used to generate a file system image for the CD called ISO image.
  3. cdda2wav: this is needed to read digital audio data from audio CDs.
All three are included in the cdrtools package you can download from www.xcdroast.org
or ftp.fokus.gmd/pub/unix/cdrecord/
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.


Installation

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 distributions available.
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
chmod 4111 /usr/bin/cdda2wav

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.
Now you can test if your CD writer is recognized correctly. Just run:

cdrecord -scanbus

If everything is alright then you should see something like:

0,6,0 6) 'PLEXTOR ' 'CD-ROM PX-W8220T ' '1.03' Removable CD-ROM

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 correctly.
So let's now finally start burning a CD.
 

General notes on burning CDs

There are four necessary steps to write CDs:
  1. You have to select the data/music you want to burn on CD
  2. 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.
  3. 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.
  4. You actually burn the CD.
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.
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.
 

Setup

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.
[xcdroast: run as root to configure] Let's look at the setup of xcdroast and koncd:
 

(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 line:
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 player.
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:

[xcdroast Duplicate CD]


Let's now look what you have to do if you want to burn a CD with music from various places:
 

(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 system.
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.

[xcdroast Master CD]

If you want to copy data from your hard disk :
[koncd Master CD]
 

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 -
Create an empty directory (known as mount point): mkdir /tmp/mycd
Mount the ISO image (connect the ISO image to the directory):
mount -o loop -t iso9660 Image.iso /tmp/mycd
Now you can use the command "ls" to inspect the CD image: ls /tmp/mycd
If it looks ok then unmount it: umount /tmp/mycd

... and burn the image to your CD.
 

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 page)
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 beginning.
Now the installation of our two little scripts is finished. Creating a data CD is now very easy:
  1. 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 MB.
  2. Run the command: mkisofseasy ~/image.iso ~/cdrom
    This will create an ISO image of all the files in the directory ~/cdrom.
  3. Burn the CD by running the command: cdrecordeasy ~/image.iso
That's it. Much easier than it looked at the beginning, isn't it!? :-)

Have fun with your CDs!

 

References

 

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:
 talkback page 

Webpages maintained by the LinuxFocus Editor team
© Katja and Guido Socher, FDL
LinuxFocus.org

Click here to report a fault or send a comment to LinuxFocus
Translation information:
en --> -- : Katja and Guido Socher <katja(at)linuxfocusorg, guido(at)linuxfocus.org>

2001-12-31, generated by lfparser version 2.23

mirror server hosted at Truenetwork, Russian Federation.