Home : Linux resources : "Howto" : Burning CDs
Here is a useful subset of cdrecord options:
[root@rgrjr /root]# cdrecord -scanbus
Cdrecord 1.10 (i586-pc-linux-gnu) Copyright (C) 1995-2001 Jörg Schilling
Linux sg driver version: 2.1.39
Using libscg version 'schily-0.5'
scsibus0:
0,0,0 0) *
0,1,0 1) *
0,2,0 2) *
0,3,0 3) *
0,4,0 4) *
0,5,0 5) 'IOMEGA ' 'ZIP 100 PLUS ' 'J.66' Removable Disk
0,6,0 6) *
0,7,0 7) *
scsibus1:
1,0,0 100) 'HL-DT-ST' 'RW/DVD GCC-4120B' '2.01' Removable CD-ROM
1,1,0 101) *
1,2,0 102) *
1,3,0 103) *
1,4,0 104) *
1,5,0 105) *
1,6,0 106) *
1,7,0 107) *
[root@rgrjr /root]#
The first time I tried this, it only found scsibus0,
which is the symptom of not having the ide-scsi driver
installed for an ATAPI drive.
cdrecord -scanbus -dev=ATAPI:
To one of the resulting list of
{scsibus,target,lun} triples, you
will need to prefix "ATAPI:" in order to tell
cdrecord to use the corresponding device, e.g. use
"-dev=ATAPI:0,0,0".
[root@rgrjr /root]# cdrecord -checkdrive -dev=1,0,0
Cdrecord 1.10 (i586-pc-linux-gnu) Copyright (C) 1995-2001 Jörg Schilling
scsidev: '1,0,0'
scsibus: 1 target: 0 lun: 0
Linux sg driver version: 2.1.39
Using libscg version 'schily-0.5'
Device type : Removable CD-ROM
Version : 0
Response Format: 1
Vendor_info : 'HL-DT-ST'
Identifikation : 'RW/DVD GCC-4120B'
Revision : '2.01'
Device seems to be: Generic mmc CD-RW.
Using generic SCSI-3/mmc CD-R driver (mmc_cdr).
Driver flags : SWABAUDIO
[root@rgrjr /root]#
[The -inq flag gets a subset of this information, mostly
the drive configuration part. -- rgr, 7-Jul-02.]
mkisofs -f -max-iso9660-filenames -relaxed-filenames -P "Bob Rogers" -V 2003Q1a \
-o foo.iso /scratch/backups/2003Q1a/cd/
cdrecord -speed=8 -dev=1,0,0 -data foo.iso
The first command makes an ISO9660 CD image out of the contents
of an ordinary Linux directory; the second command writes this
image to the drive. It is split up this way into two operations
because the writing must be done in real time; the CPU has to
ensure that the data gets to the CD in time to be written. The
two operations can be pipelined (see the next item), which
eliminates the temp hard drive space usage, but doing them separately
ensures that the CD image is burned correctly onto the blank
medium.
mkisofs -max-iso9660-filenames -relaxed-filenames -V 2003Q1a /scratch/backups/cd/2003Q1a \
| cdrecord -dev=1,0,0 -speed=8 -
This turns out to be much faster for me than doing the two
steps separately. The reason is that I have only one hard drive, so
making a ISO9660 image file from content on the same hard drive
requires lots of seeks, which are time-consuming.
The drive is capable of writing a CD-R disk at 4X, 8X, and 12X, but attempting to write at 12X on my old system results in an unreadable CD -- mount complains about a bad superblock, among other possibilities. This is probably because this machine can't shovel the data fast enough, and so the pipeline stalls. I notice that xload shows significantly higher CPU demand when writing at 12X than at 8X or 4X, so perhaps the CPU (a 300MHz Athlon processor) is the limiting factor. My new machine (with a 1.8GHz AMD chip) has no problems writing at full speed.
[add -hfs --netatalk to make a Mac-readable CD. -- rgr, 22-Sep-02.]
Usually, both mkisofs and cdrecord need extra instruction on how and whether to write a multi-session CD:
According to the cdrecord man page,
The fixation will be done in a way that allows the CD-Recorder to append additional sessions later. This is done by generating a TOC with a link to the next program area. The CD thus written is not 100% compatible to manufactured CDs.[From the version 1.10 description of "-multi", edited slightly for readability. -- rgr, 20-Oct-02.]
For example, here's a first session being written to a blank CD in the drive at logical address "1,0,0":
mkisofs /scratch/backups/2003Q1a | cdrecord -dev=1,0,0 -speed=8 -multi -
The second and subsequent sessions look like this:
mkisofs -C `cdrecord -dev=1,0,0 -msinfo` -M 1,0,0 /scratch/backups/test \
| cdrecord -dev=1,0,0 -speed=8 -multi -waiti -
To write a final session, use something based on the second
session example but drop the "-multi" option.
First, you need to put the CD in the drive (but don't mount it), and then copy the raw CD image onto a file on the hard drive:
dd if=/dev/cdrom of=/scratch/backups/cd-image.iso9660
You may need to substitute "/dev/cdrom" with whatever
the device is named on your system; see /etc/fstab for
hints. (If you have a USB burner, it will only show up when
powered on and plugged in.) Then, mount it wherever you like as
an ISO9660 file system via a "loop device:"
mount cd-image.iso9660 /mnt/cdrom -t iso9660 -o loop
See the "THE LOOP DEVICE" section of the mount
man page for more details.
to_write_subdir=.
mkisofs_cmd='mkisofs -max-iso9660-filenames -relaxed-filenames -quiet'
disk_size=`$mkisofs_cmd -print-size $to_write_subdir`
$mkisofs_cmd $to_write_subdir \
| cdrecord-wrapper.sh -dao -multi -tsize=${disk_size}s -dev=0,0,0 -
Note that the key thing is to specify -tsize to
cdrecord-wrapper.sh, so you need to run mkisofs
with the -print-size option, ensuring that you use the
exact same options in both places.
mkisofs and
cdrecord to burn files and/or directories to CD. (Despite
the name, they need not be "dump" files.) File integrity is verified
after burning and, if the data on the CD is good, the input files are
moved to "written" directory.
Usage for this is
cd-dump.pl [--help] [--man] [--verbose] [--test]
[--dev=x,y,z ] [--[no]mount] [--max-iso9660-filenames]
[--relaxed-filenames] [-V=<volname>] [--speed=n]
[--to-write-subdir=<directory>] [--written-subdir=<directory>]
See the cd-dump.pl man
page for argument descriptions, and other details.
Downloading:
You will need two things: