Get Firefox! Viewable with any browser! Valid HTML 4.01! Valid CSS!
Text size: 

CD Writing Howto


This is a technique often used to provide computer games with background music without tying up the CPU, which already has enough to do. Instead of wasting CPU cycles generating the background music from mod files and then mixing it with the game's sound FX, the background music is simply played back from a CDDA track. This means that we have both an ISO data track and 1 or more (up to 98 in fact) audio tracks, and it is usually accomplished in one of two different manners.

Data in track 1

A while ago I bought a (legitimate!!) copy of Tomb Raider. Rather than use the original CD all the time, I wanted to make a backup of it and use that backup while keeping the original CD in a safe place. REMINDER: THIS WAS NOT PIRACY, THIS WAS MAKING A BACKUP FOR PERSONAL USE. Had I been a Linux user at the time, this is how I would have made a copy of the CD using the tools discussed in this howto.

The CD has 10 tracks all in all. The first one is a data track with an ISO filesystem containing the game's files. Tracks 2 to 10 are audio tracks.

The first step is to replicate the filesystem in the data track. This can be accomplished in either one of 2 ways:

  1. Mount the CDROM on its usual mountpoint. Assuming that mountpoint is /mnt/cdrom, you now make another ISO filesystem with this command:

    # mkisofs -o tombraider.iso /mnt/cdrom

    There's no need for any of the filesystem extensions on this particular CD-ROM because it is a DOS game, and there's no such thing as a long filename in DOS.

    Finally unmount the CDROM.

  2. Mount the CDROM and use the df command to find out the exact size of the ISO filesystem.

    # mount -t iso9660 /dev/scd0 /mnt/cdrom -o ro
    # df | grep cdrom
    /dev/scd0 174402 174402 0 100% /mnt/cdrom

    This tells me that the ISO filesystem is 174402 kilobytes in length. Since the data sectors are 2 kilobytes in length, there are 174402/2=87201 sectors of data. We can plug that information into the dd command and make a bitwise clone of the ISO track. Unmount the CDROM first:

    # umount /mnt/cdrom
    # dd if=/dev/scd0 of=tombraider.iso bs=2048 count=87201
    87201+0 records in
    87201+0 records out

    The tombraider.iso file is now an exact replica of the original data track on the CDROM.

Now we have to rip the audio data out of tracks 2 to 10:

# cdparanoia -d /dev/scd0 -B 2-10 tomb.wav

This will rip tracks 2 to 10 and save the data in files called track02.tomb.wav, track03.tomb.wav etc... up to track10.tomb.wav.

The final step is to write the whole lot to a blank CD. Note that since we're writing audio tracks, we're going to stick with a low write speed and therefore a relatively small FIFO. We'll also be meeting cdrecord's -data command line parameter.

Basically, -data tells cdrecord that all the files which follow are to be written as data tracks until a contradictory order (such as an -audio command line parameter) is met.

What we want to do is start by writing the data track tombraider.iso, then the audio tracks. The command line is going to look like this:

# cdrecord dev=0,0 speed=4 fs=4m -v -eject -data tombraider.iso -audio track*tomb.wav


Older audio CD decks had significant problems with CD's having data in the 1st track. They could crash, or they would attempt to play back the digital data and make a horrible noise!

Various attempts to kludge round the problem were made, such as putting the ISO filesystem in a huge pregap before the first audio track but even that would end up getting played back if the user was stubborn enough to rewind to before the beginning of that audio track.

The best solution so far is the use of multisession CDs.

The audio tracks (up to 98 of them) are recorded into the first session. The final lead-out isn't written, but a second session is opened and we put the data track in there before fixating the disc. This is what's known as a "CD-Extra".

Audio CD decks are no longer bothered by the data track because they can't see it (they can only see the first session), and computer CDROM drives only see the last track, i.e. the track with the data, unless otherwise instructed.

This means that we're going to have to invoke cdrecord three times:

  1. Write the audio tracks to the CD, but in multisession mode:

    # cdrecord dev=0,0 fs=4m speed=4 -v -multi -audio list_of_audio_tracks

  2. Find out the extent of the session just written:

    # cdrecord dev=0,0 -msinfo

    This information will be used when you build your ISO image with mkisofs and the -C command line parameter (see "Multisession CD-ROMs").

  3. Write the data session:

    # cdrecord dev=0,0 speed=8 fs=16mb -v -eject your_iso_filesystem.iso

    Note that we're no longer writing audio tracks here so we can boost the write speed.

Voilà! Put this CD in an audio CD deck and it'll play back your audio tracks (unless it was a CDRW), and put it in a computer and you'll get the data you recorded.


<< 10) Using audio tracks 12) Notes for FreeBSD users >>

Back to the howto title page
Back to