Writing ISO Images to CD with cdrecord

 in
You can't simply cp a CD image onto a new disk. For this task, you need the cdrecord program.

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 copy it to a CD. Today, with the availability of GUI-based CD creation programs such as K3B, the old command-line method is pretty much forgotten.

Those GUIs are fine for building a CD from ordinary files stored on your hard disk--text, data, music and such--but sometimes you need to do the equivalent of copying a CD image onto a new CD. A common occurrence of this is with a Linux distribution. For example, Knoppix is distributed in this manner, as is the SuSE Live Evaluation.

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

Fortunately, there is a program that understands how to deal with writing CDs like this 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 know the address at which your CD writer lives on the bus, you should enter cdrecord -scanbus. This command scans for devices and prints 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 of output that matters 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 cdrecord program.

Most likely this is all the information you need to have, 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 be enough. Optionally, the -v option gives you a little more information when the program is running. On my system, for example, I enter the following to write the SuSE 9.0 ISO image:


cdrecord -v dev=0,4,0 Suse-9.0*iso

The *, of course, is a shell wildcard that saves me from typing a very long file name. For comparison's sake, this is what the command's output looks like:


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
(okir@suse.de-scsi-linux-sg.c-1.75-resmgr-patch '@(#)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
session.
Last chance to quit, starting real write    0 seconds. Operation
starts.
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
sectors).
Writing  time:  400.168s
Average write speed  11.9x.
Min drive buffer fill was 99%
Fixating...
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, as well as one very important piece of information. In the last line, cdrecord tells you if the FIFO ever was empty and how low it ever got. This is the buffer to the device. You are transferring 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.

Copyright (c) 2004, LG Staff. Originally published in Linux Gazette issue 98. Copyright (c) 2004, Specialized Systems Consultants, Inc.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Command Name Changed

Anonymous's picture

The cdrecord command has changed in some (all?) distros.
The current command name is: wodim

The cdrecord command is still availble, but it is merely a sim-link to the wodim command.

It's 'great' for Linux, because we're supposed to use 'wodim' but all the help & online articles reference 'cdrecord' ...

"You can't simply cp a CD

Anonymous's picture

"You can't simply cp a CD image onto a new disk." - if cdrecord was designed properly that should have been the end-goal.

Um, in OS/2 (and eCS for

Anonymous's picture

Um, in OS/2 (and eCS for that) we can just copy stuff to our CD drives. While I do like a lot of what linux groups are doing, shouldn't this be the end goal of cdrecord- to make CDs and DVDs transparent to the end users as a type of medium? As long as it holds data, you should be able to treat it like anything else on the system. Just like FTP and such. You shouldn't need extra commands to get it done.

Printer friendly version of Writing ISO images

Anonymous's picture

The printer friendly version prints fine but the indented section
goes byond the print margin (HP1350 on win 98) and is cut off.
In other words not completely friendly.

Printer friendly version of Writing ISO images

Keith Daniels's picture

I checked the printer friendly layout and couldn't get the problem to replicate on my system. There are several things that could cause this but most probably it is a printer font setting or a lack of a specific font being available that is causing the problem.

If you want me to help you with this email me at webmaster@ssc.com with "printer friendly problem" in the subject line.

All the new OSs and windowing systems are oriented towards content consumption instead of content production.

--Steve Daniels 2013

I have the same SCSI based

Anonymous's picture

I have the same SCSI based HP 9600 CD Writer.I used K3B for a long time on Suse 9.2 and before. Since I upgraded to OpenSuse 10, every time I launch K3B, it locks up after trying to locate the device and I have to force terminate it. As a work around, I have been using this method and working very well. I like K3B and like to solve this issue, has any one encountered this problem and have a fix for it? Much appreciated.

no problem at all

Peter Schudt's picture

Greetings. I use the same config but this software never did to me what you described. Hmm - maybe there is a hardware problem.

This information is

Anonymous's picture

This information is outdated. With Linux 2.6 you don't need scanbus and device numbers any more. Just "cdrecord -dev=/dev/hdc" or whatever your CD drive is called.

thanks

Anonymous's picture

that was exactly what I needed, just upgraded to kernel 2.6 and
cdrecord stopped working since I lost the scsi emulation. such a
simple fix but I couldn't find it mentioned in the cdrecord documentation.

cdrecord documentation

deelip's picture

hi. frd i need cdrecord documentation for writing data to disc .not to depend on whatever the writer is.. kindly help me to make a gui for cd writing ..

But how do you know what

Anonymous's picture

But how do you know what your CD-ROM is called?

dmesg | more and look for

Anonymous's picture

dmesg | more
and look for CDROM

or try cdrecord dev=/dev/hdb

Anonymous's picture

or try
cdrecord dev=/dev/hdb -checkdrive
cdrecord dev=/dev/hdc -checkdrive
cdrecord dev=/dev/hdd -checkdrive
etc
until something works?

dmesg | grep CD

Anonymous's picture

dmesg | grep CD

Or under a standard udev system /dev/cdwriter unless you have very obscure hardware.

Or just know what your writer is connected to - /dev/hdc for secondary master, /dev/hdb for primary slave, etc

The command (for CentOS and

Anonymous's picture

The command (for CentOS and maybe Fedora based distros) that works for me with and LG CD-DVD writer to copy a .iso was: cdrecord -v -sao dev=/dev/dvdwriter /.iso

>Those GUIs are fine for

Anonymous's picture

>Those GUIs are fine for building a CD from ordinary files stored on your hard disk--text, data, music and such--but sometimes you need to do the equivalent of copying a CD image onto a new CD.

Right-click iso file and select "Write to Disc"?

Good, except...

Anonymous's picture

cdrecord is good, useful software, so long as you don't have to deal directly with its developer. He is a bit, shall we say, difficult to work with when it comes to Linux.

Download, not discuss 8-)

Alex Malukko's picture

Well, well - as a user I am downloading this software and not discussing it with the developer 8-))))

Make-CD script

CraigM's picture

I've written a small Perl script that I use to make a CD based on a directory layout. It's called "make-cd", and it's available at:

http://decafbad.net/projects/scripts/make-cd.tar.gz

Might make it a little easier for people to create CDs without having to remember a lot of command line options and commands.

Hope this helps!

Make-CD script

CraigM's picture

I've moved the location of this script:

http://decafbad.net/files/make-cd.tar.gz

Sorry for the inconvenience.

deprecated

asd's picture

This "howto" is way too old deprecated (1 technical one: ide-scsi is no more needed if you are using 2.6, which is out for a while now, plus most ppl are using dvd now - mostly with growisofs||dvdrecord)

Yes DVDs are being used

andrew's picture

Yes DVDs are being used alot, but that doesn't preclude the need to write CD's. Perhaps a followup to this article will be writing DVD's with dvd-record or some such. This is still a good article for someone who doesn't know how to do this yet. I do agree that mention should be made that ide-scsi is no longer needed with the 2.6 kernel.

Still... Use K3b

Anonymous's picture

I agree with the ide-scsi comments.

However, for the typical luser, using K3b is going to be much easier. I guess this author never noticed the menu options for burning a CD (or DVD) from an ISO image. And K3b can create the ISO image, then allow the "project" to be saved. If you update the individual files that are part of the project, you can open K3b, load in the (old) project, and burn another ISO and automatically get the new file contents. (I use this for adding my own content to SUSE and FC DVD images.)

Btw, growisofs only works on DVDs (and most of them, but not all). Yet that's hidden by K3b, so the user just says "burn CD" or "burn DVD" and off it goes!

Relying on K3B or other

Anonymous's picture

Relying on K3B or other GUI-based tools to burn a disk is not sufficient. I am at this very moment burning a new Kubuntu CD using cdrecord because my KDE is all screwed up and K3B (among other things) segfaults when I try to start it.

Newer is not always better, and having a Plan B is often a very valuable thing. Rock on, cdrecord!

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix