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.
Special Magazine Offer -- Free Gift with Subscription
Receive a free digital copy of Linux Journal's System Administration Special Edition as well as instant online access to current and past issues. CLICK HERE for offer
Linux Journal: delivering readers the advice and inspiration they need to get the most out of their Linux systems since 1994.
Subscribe now!
The Latest
Newsletter
Tech Tip Videos
- Jul-01-09
- Jun-29-09
Recently Popular
From the Magazine
July 2009, #183
News Flash: Linux Kernel 3.0 to include an on-the-go Expresso machine interface! Ok, maybe not, but Linux is definitely going mobile, from phones to e-readers. Find out more inside about Android, the Kindle 2, the Western Digital MyBook II, The Bug, and Indamixx (a portable recording studio). And if you've gone mobile and you been wanting more Emacs in your life then check out Conkeror.
To compliment the mobile we've got the stationary: parsing command line options with getopt, checking your Ruby code with metric_fu, and building a secure Squid proxy. How is this stationary you ask? What can we say? It's not. We just wanted to see if anybody actually read this part of the page :) .
All this and more, and all you have to do is get your hot sweaty hands on the latest copy of Linux Journal.
Delicious
Digg
StumbleUpon
Reddit
Facebook








"You can't simply cp a CD
On February 2nd, 2006 Anonymous (not verified) says:
"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
On February 6th, 2006 Anonymous (not verified) says:
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
On January 28th, 2006 Anonymous (not verified) says:
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
On January 30th, 2006 Keith Daniels says:
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.
I have the same SCSI based
On January 26th, 2006 Anonymous (not verified) says:
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
On January 28th, 2006 Peter Schudt (not verified) says:
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
On January 26th, 2006 Anonymous (not verified) says:
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
On July 12th, 2006 Anonymous (not verified) says:
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
On January 30th, 2007 deelip (not verified) says:
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
On February 1st, 2006 Anonymous (not verified) says:
But how do you know what your CD-ROM is called?
dmesg | more and look for
On February 3rd, 2006 Anonymous (not verified) says:
dmesg | more
and look for CDROM
or try cdrecord dev=/dev/hdb
On April 12th, 2006 Anonymous (not verified) says:
or try
cdrecord dev=/dev/hdb -checkdrive
cdrecord dev=/dev/hdc -checkdrive
cdrecord dev=/dev/hdd -checkdrive
etc
until something works?
dmesg | grep CD
On March 6th, 2006 Anonymous (not verified) says:
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
On January 11th, 2007 Anonymous (not verified) says:
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
On January 26th, 2006 Anonymous (not verified) says:
>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...
On January 26th, 2006 Anonymous (not verified) says:
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-)
On January 28th, 2006 Alex Malukko (not verified) says:
Well, well - as a user I am downloading this software and not discussing it with the developer 8-))))
Make-CD script
On January 26th, 2006 CraigM (not verified) says:
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
On August 27th, 2006 CraigM (not verified) says:
I've moved the location of this script:
http://decafbad.net/files/make-cd.tar.gz
Sorry for the inconvenience.
deprecated
On January 25th, 2006 asd (not verified) says:
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
On January 25th, 2006 andrew (not verified) says:
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
On January 25th, 2006 Anonymous (not verified) says:
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
On June 8th, 2008 Anonymous (not verified) says:
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!
Post new comment