Burning CDs with cdrecord

The following instructions have been used on a Red Hat Linux 9 system.

Determining CD recorder path

To determine the device path of your CD recorder:
cdrecord -scanbus
drecord 1.10 (i686-pc-linux-gnu) Copyright (C) 1995-2001 J�rg Schilling
Linux sg driver version: 3.1.24
Using libscg version 'schily-0.5'
scsibus0:
        0,0,0     0) 'ATAPI   ' 'CD-RW 48X16     ' 'A.UZ' Removable CD-ROM
        0,1,0     1) *
        0,2,0     2) *
        0,3,0     3) *
        0,4,0     4) *
        0,5,0     5) *
        0,6,0     6) *
        0,7,0     7) *

In this example, the path to my CD recorder is 0,0,0.

If you do not see any CD recorders in the output of cdrecord -scanbus, see if the ide-scsi kernel module is loaded:
/sbin/lsmod | grep ide-scsi
ide-scsi               10512   2
scsi_mod              107176   3  (autoclean) [sg ide-scsi sr_mod]


If you do not see ide-scsi or scsi_mod, type modprobe ide-scsi to load the ide-scsi kernel module and its dependencies.

Creating ISO images

To create an ISO image from a CD:
dd if=/dev/cdrom of=ISO_file.iso

Note: you may want to experiement with dd's bs (blocksize) parameter to speed up the process. I've found that using bs=1M (1 megabyte) to read and write 1 megabyte is more efficient than the default blocksize and other  (higher and lower) settings.

To burn an ISO image to a CD (assuming CD record device path of 0,0,0 and 48x burn rate):
cdrecord dev=0,0,0 -data speed=48 ISO_file.iso

Make sure to adjust the device path and speed accordingly for your system.

Creating an ISO file systems with mkisofs

If the CD will be read on UNIX systems, enable Rock Ridge extensions (-r) for long filename, UID/GID, permissions, symbolic link, and block/character device support.

Enable Joliet extensions (-J) for long filename support on Windows systems.

Enable HFS support (-hfs) for support on Macintosh systems.

Example: Creating an ISO9660 file system with Rock Ridge, Joliet, and HFS support.
mkisofs -o ISO_image -r -J -hfs cd_dir

cd_dir will appear to be the root of the ISO9660 file system.


Mounting an ISO image as a file system

It is possible to mount an ISO image using the loop file system:
mount -o loop,ro -t iso9660 ISO_image mount_point

If the operation fails, try loading the loop kernel module with modprobe loop.

Burning MP3s onto an audio CD

In order to burn MP3s as an audio CD, you first have to convert the MP3's to .wav format. The mpg123 tool (part of the mpg321 package) is able to do this.

The following script may be used to burn all MP3s in the current directory as an audio CD. The script first converts all spaces in MP3 filenames to underscores. The MP3s are then decoded into .wav files. Finally, cdrecord burns the .wav files to disc. The script assumes a CD recorder device path of 0,0,0 and a 48x burn rate. For more information, see the Linux MP3 CD Burning mini-HOWTO.

#!/bin/sh

# Convert files containing spaces to underscores
for i in *.mp3; do mv "$i" `echo $i | tr ' ' '_'`; done

# Convert MP3s to WAV files
for i in *.mp3; do mpg123 -w `basename $i .mp3`.wav $i; done

# Burn the CD
cdrecord dev=0,0,0 -eject speed=48 -pad -audio *.wav


Erasing a CD-RW

To erase a CD-RW, use cdrecord's blank option.
ex. cdrecord -v dev=0,0,0 blank-fast

cdrecord blank=help
Blanking options:
        all             blank the entire disk
        disc            blank the entire disk
        disk            blank the entire disk
        fast            minimally blank the entire disk (PMA, TOC, pregap)
        minimal         minimally blank the entire disk (PMA, TOC, pregap)
        track           blank a track
        unreserve       unreserve a track
        trtail          blank a track tail
        unclose         unclose last session
        session         blank last session

Back to brandonhutchinson.com.
Last modified: 12/26/2003