Home | VizagInfo Mirror of LG

<< Prev  |  TOC  |  Front Page  |  Talkback  |  FAQ  |  Next >>
...making Linux just a little more fun!
Take Command: cdrecord (Writing ISO Images to CD)
By LG Staff

Take Command: cdrecord (Writing ISO Images to CD) Home | VizagInfo Mirror of LG

Take Command: cdrecord (Writing ISO Images to CD)

In the old command-line days, about the only way to write a CD-ROM on a Linux system was to know the set of commands that build an ISO filesystem and then copied it to a CD. Today, with GUI-based CD creation programs such as K3B, the old command-line method is pretty much forgotten.

That's fine for building a CD from ordinary files stored on your hard disk (that is, text, data, music and such) but sometimes you need to do the equivalent of copying a CD image onto a new CD. A common place where this happens is with a Linux distribution. For example, Knoppix is distributed like this as is the SuSE Live Evaluation.

You might think that using cp or dd would do the task. After all, to us UNIX people, a file is a file. Unfortunately that doesn't work with creating CDs because you can't just write bits to the CD and be home free.

Fortunately, there is a program that understands how to deal with writing CDs and isolates you from most of the pain. The program is cdrecord and most GUI-based CD creation programs actually use cdrecord to do the actual writing.

Unless you what address your CD writer lives at on the bus, you will want to enter
cdrecord -scanbus
This command will scan for devices and print out their addresses in the format that cdrecord wants. Note that I am doing this with a SCSI CD writer. I am not sure what you will see with an IDE device.

In my case, the line that matters in the output is

0,4,0  4) 'HP  ' 'CD-Writer+ 9600 ' '1.0a' Removable CD-ROM
and the 0,4,0 in the line is the information I need to feed to the program.

It is likely that this is all the information you will need as cdrecord polls the device and seems to default well. If this is not the case, grab the manual for your CD writer, type man cdrecord and start reading.

Assuming you don't want to get fancy, a command line with dev= followed by the device and then the name of the ISO image to write out should do it. Optionally, the -v option will give you a little more information when the program is running.

For example, on my system, to write the SuSE 9.0 ISO image, I entered
cdrecord -v dev=0,4,0 Suse-9.0*iso
The *, of course, is just a shell wildcard to save me typing a very long file name.

Just for comparison, this is what my output looks like from the command.

Cdrecord 2.0 (i686-suse-linux) Copyright (C) 1995-2002 Jörg Schilling
TOC Type: 1 = CD-ROM
cdrecord: Warning: not running as root user, fs= option ignored.
scsidev: '0,4,0'
scsibus: 0 target: 4 lun: 0
Linux sg driver version: 3.1.24
Using libscg version 'schily-0.7'
cdrecord: Warning: using inofficial libscg transport code version
( '@(#)scsi-linux-sg.c
1.75 02/10/21 Copyright 1997 J. Schilling').
atapi: 0
Device type    : Removable CD-ROM
Version        : 4
Response Format: 2
Capabilities   : SYNC
Vendor_info    : 'HP      '
Identifikation : 'CD-Writer+ 9600 '
Revision       : '1.0a'
Device seems to be: Generic mmc CD-RW.
Using generic SCSI-3/mmc CD-R driver (mmc_cdr).
Driver flags   : MMC-2 SWABAUDIO
Supported modes: TAO PACKET SAO SAO/R96R RAW/R96R
Drive buf size : 4183552 = 4085 KB
FIFO size      : 4194304 = 4096 KB
Track 01: data   648 MB
Total size:      745 MB (73:50.37) = 332278 sectors
Lout start:      745 MB (73:52/28) = 332278 sectors
Current Secsize: 2048
ATIP info from disk:
  Indicated writing power: 7
  Is not unrestricted
  Is not erasable
  ATIP start of lead in:  -11597 (97:27/28)
  ATIP start of lead out: 336601 (74:50/01)
Disk type:    Short strategy type (Phthalocyanine or similar)
Manuf. index: 20
Manufacturer: Princo Corporation
Blocks total: 336601 Blocks current: 336601 Blocks remaining: 4323
RBlocks total: 346489 RBlocks current: 346489 RBlocks remaining: 14211
Starting to write CD/DVD at speed 12 in real TAO mode for single
Last chance to quit, starting real write    0 seconds. Operation
Waiting for reader process to fill input buffer ... input buffer ready.
Performing OPC...
Starting new track at sector: 0
Track 01:  648 of  648 MB written (fifo 100%) [buf  99%]  12.1x.
Track 01: Total bytes read/written: 680501248/680501248 (332276
Writing  time:  400.168s
Average write speed  11.9x.
Min drive buffer fill was 99%
Fixating time:   22.958s
cdrecord: fifo had 10719 puts and 10719 gets.
cdrecord: fifo was 0 times empty and 10592 times full, min fill was 93%.

There is some useful information in there and one very important piece of information. In the last line, cdrecord tells you if the FIFO was ever empty and, also, how low it ever got. This is the buffer to the device. You are transfering the data to the CD in real time. If the FIFO is ever empty, the CD will be corrupted. The minimum fill percentage is a good way to check how close you are to not keeping up. If this number gets fairly low, you should stop all unnecessary processes when you are writing a CD.

Unless otherwise mentioned, this work copyright © 2003-2004 by SSC, Inc. All rights reserved.


[BIO] Linux Gazette staff and authors.

Copyright © 2004, LG Staff. Copying license
Published in Issue 98 of Linux Gazette, January 2004

<< Prev  |  TOC  |  Front Page  |  Talkback  |  FAQ  |  Next >>