|s i s t e m a o p e r a c i o n a l m a g n u x l i n u x||~/ · documentação · suporte · sobre|
"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.)
Writing CD-ROMs consists of two steps under Linux:
This chapter describes the steps for data and audio CDs in greater detail.
Note that collecting the data to put onto a CD usually takes longer than one expects. Consider that missing files cannot be added once the CD is written and fixated. This is also true for CD-RW, which can currently only be rewritten as a whole. Using the multi-session feature is no option for single files, as it consumes much space for a new complete table of contents (TOC). UDF is not ready yet for Linux.
Also keep in mind that a certain amount of the free space of a CD is used for storing the information of the ISO-9660-filesystem (usually a few MB). 620 MB data will always fit on a 650 MB CD-R.
Creating an image of the later CD-ROM
Before any storage medium (e.g. floppy disk, hard disk or CD) can be used, it must get a filesystem (DOS speak: get formatted). The filesystem is responsible for organizing and incorporating the files that should be stored on the medium.
The usual utilities for creating filesystems on hard disk partitions write an empty filesystem onto them, which is then mounted and filled with files by the users as they need it. A writable CD is only writable once so if we wrote an empty filesystem to it, it would get formatted and remain completely empty forever. This is also true for rewritable media as you cannot change arbitrary sectors yet; you must erase their whole content.
So what we need is a tool that creates the filesystem while copying the
files to the CD. This tool is called
The option '-r' sets the permissions of all files to be public readable on
the CD and enables RockRidge-extensions. You probably want to use this option
unless you really know what you're doing
(hint: without '-r' the mount point gets the permissions of
Remeber do use the Option -J (MS Joliet extensions) or use mkhybrid if you want to generate a more Windows-friendly CD-ROM. For HFS CD-ROMS used on the Macintosh, you better read the man-page of mkisofs' bigger sister mkhybrid for details on various options.
Now you may wonder why the output of
There is a method to write a CD-R in one go, which will be described below.
One also could think of creating an extra partition and writing the image to that partition instead to a file. I vote against such a strategy because if you write to the wrong partition due to a typo, you can lose your complete Linux system. Read: that happened to me... Furthermore, it is a waste of disk space because the CD-image is temporary data that can be deleted after writing the CD. However, using raw partitions saves you the time for deleting files of 650 MB size.
Test the CD-image
Linux has the ability to mount files as if they were disk partitions. This feature is useful to check that the directory layout and file access permissions of the CD image matches your wishes. Although media is very cheap today, the writing process is still time consuming, and you may at least want to save your time by doing a quick test.
To mount the file
Now you can inspect the files under
Some ancient versions of
Write the CD-image to a CD
This section only covers writing data CDs in TAO mode, because it is the most frequently used mode for data. For more information about the differences of TAO and DAO, please see the chapter about audio CD-Rs. If you use DAO mode with the tool cdrdao, then remember to add a dummy audio track at the end of the TOC file (see the README).
Not much more left to do. If you haven't already tried, it's a good time for the command
This will tell you to which SCSI device your CD-writer is attached to. All other methods of guessing the information printed so nicely by cdrecord have been removed from the HOWTO.
Before showing you the last command, let me warn you that CD-writers want to be fed with a constant stream of data. So the process of writing the CD image to the CD must not be interrupted or a corrupt CD will result. It's easy to interrupt the data stream by deleting a very large file. Example: if you delete an old CD-image of 650 Mbytes size, the kernel must update information about 650,000 blocks on the hard disk (assuming you have a block size of 1 Kbyte for your filesystem). That takes some time and is very likely to slow down disk activity long enough for the data stream to pause for a few seconds. However, reading mail, browsing the web, or even compiling a kernel generally will not affect the writing process on modern machines.
Please note that no writer can re-position its laser and continue at the original spot on the CD when it gets disturbed. Therefore any strong vibrations or other mechanical shocks will probably destroy the CD you are writing.
When you are mentally prepared, dress up in a black robe, multiply the SCSI-id of the CD-writer with its SCSI-revision and light as many candles, speak two verses of the ASR-FAQ (newsgroup alt.sysadmin.recovery) and finally type:
For better readability, the coordinates of the writer are stored in three environment variables with natural names: SCSI_BUS, SCSI_ID, SCSI_LUN.
If you use cdrecord to overwrite a CD-RW, you must add the option "blank=..." to erase the old content. Please read the man page to learn more about the various methods to blank the CD-RW.
In times where everybody except me owns a 400 Mhz machine, people feed the output of mkisofs directly into cdrecord:
The first command is an empty run to determine the size of the image (you need the mkisofs from the cdrecord distribution for this to work). You need to specify all parameters you will use on the final run (e.g. -J or -hfs). Maybe your writer does not need to know the size of the image to be written, so you can leave this dry run out. The printed size must be passed as a tsize-parameter to cdrecord (it is stored in the environment variable IMG_SIZE). The second command is a sequence of mkisofs and cdrecord, coupled via a pipe.
Writing audio CDs is very similar to the steps described above for data CDs. You can choose between two techniques: DAO or TAO. TAO (track at once) is less suitable for music, because you will hear clicks between the individual tracks. It is described first anyways, because it is a little bit easier to deal with and DAO is not available for all drives yet.
The main difference compared to writing data CD-Rs is the format of the images. ISO-9660 (or whatever filesystem you prefer) would not be suitable, because no audio CD player is able to deal with filesystems. Instead the audio data must be writen as "16 bit stereo samples in PCM coding at 44100 samples/second (44.1 kHz)".
One utility to convert your sound files into the required format is sox. Its usage is straightforward:
This command would convert the song killing-my-software from the WAV-format into the CDR audio-format. See the man page for sox for more details about formats and filename-extensions sox recognizes. Because the output of the manual conversion takes up much disk space, it was made a built-in feature of cdrecord for the sound formats WAV and AU. So as long as your sound files have the extensions .wav or .au (and the sample rate "stereo, 16 bit, 44.1 kHz"), you can use them as audio tracks without manual conversion into the CDR format. However, cdrecord requires the size of the sound data to be a integer multiple of 2352 and to be greater than 705,600 bytes, which is not fullfilled for some WAV files. For such files the usage of sox is needed to pad the audio data up to 2352 bytes.
Writing audio CDs (TAO)
An audio CD consists of audio tracks, which are organized as separate images when using TAO mode. So if you want to have ten tracks on your CD, you have to make ten images.
Cdrecord writes CD images as audio tracks if the option -audio is specified. The other options are identical to those used for writing data-CDs (unless you have very special requirements). These three examples all do the same thing, but read the tracks from different sound file formats:
By doing this, you will produce an audio CD which has a 2 seconds of pause between audio tracks. One notable format not directly readable by cdrecord is MPEG Layer 3. To convert files in this format to the CDR-format, you can use the command "mpg123 --cdr - track1.mp3 > track1.cdr". The option --cdr ensures the track is encoded in the required format (see above). Older versions of mpg123 require -s instead of the plain - to write to stdout. The other direction (converting from WAV to MPEG) can be done with LAME for WAV-files (extract the track with cdda2wav from the audio CD and encode it into MP3 with the help of LAME).
To create a CD-R from a whole bunch of MP3-files, you can use the following command sequence:
Depending on the speed of your machine, you may want to slow down writing to "speed=1" (cdrecord option). If you use "speed=4", your machine must be able to play the MP3-file at quadruple speed. mpg123 consumes much CPU-time! If you are in doubt, try an empty run with -dummy (keeps the laser switched off).
If you want to get rid of the pauses between the audio tracks, you have to use disk-at-once (DAO) recording versus the (individual) track-at-once (TAO) recording described above. Support for DAO is currently most advanced in cdrdao. Please see its homepage for details.
If you master the CD in DAO mode, then you use a monolithic image (sound file) and control track information with a configuration file.
There is not much to say about this topic. Just indicate the type of the (subse quent) images with the options -data and -audio. Example:
Next Previous Contents