Burning CD-Rs or CD-RWs in Linux


Introduction

cdrtools is a set of utilities for recording cds in the Linux operating system.  It is the only set of utilities supported by Physics Computing Services for this purpose.  Use of these tools requires installation of the software, as well as SCSI drivers and possibly other supporting software.  This document assumes you have already had these requirements setup by PCS.

Writing CD-ROMs consists of two steps under Linux:

Creating an ISO image of your data

Before the data can be burned with cdrecord, the cdrtools recording utility, it must be "mastered" using the mkisofs utility.  This utility simply creates an iso filesystem image from the data required.  Please remember that this file MUST be less than 650M (usually shoot for 600 to be safe), and that therefore the data your feeding it must also total less than this amount.  Also you must have that amount of space free in the directory you want to temporarily store the ISO.  To see how much space the files in a directory are taking up, type

    du -k


in that directory.  That will display the total size of all files, in kilobytes.

Once you have a directory with all the data you'd like to dump to a CD-R or CD-RW in it, type the following:

    mkisofs -R -o <ISO-filename> <directory-of-files-to-burn>


You should get back a bunch of lines giving you status updates with percent complete and ETA, and then at the end some summary data about how much was written.  Now you have an ISOimage to burn-- it's time to set up the writer...

Burn the image to CD-R or CD-RW

There's not much more left to do. If you haven't already tried, it's a good time for the command

 % sudo cdrecord -scanbus
This will tell you to which SCSI device your CD-writer is attached to:

Cdrecord-Clone 2.01 (i686-pc-linux-gnu) Copyright (C) 1995-2004 Jörg Schilling
Linux sg driver version: 3.1.24
Using libscg version 'schily-0.8'.
scsibus0:
        0,0,0     0) '_NEC    ' 'DVD+RW ND-1100A ' '108B' 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 the example above, the writer is attached at SCSI bus 0,  SCSI ID 0, SCSI LUN 0.    Make note of this location.

Now you can insert the blank CD-R or CD-RW into the drive.  Then, execute the following command (be sure to adjust your parameters according to the output of cdrecord -scanbus):

 % sudo cdrecord -dummy -v dev-0,0,0 <name_of_your_iso_image>

which will do a test-run to make sure all configurations are correct and usable. 

Before showing you the last command, let us warn you that CD-writers want to be fed with a constant stream of data. So the process of writing the CD image to the CD must not be interrupted or a corrupt CD will result. It's easy to interrupt the data stream by deleting a very large file. Example: if you delete an old CD-image of 650 Mbytes size, the kernel must update information about 650,000 blocks on the hard disk (assuming you have a block size of 1 Kbyte for your filesystem). That takes some time and is very likely to slow down disk activity long enough for the data stream to pause for a few seconds. However, reading mail, browsing the web, or even compiling a kernel generally will not affect the writing process on modern machines.

Please note that no writer can re-position its laser and continue at the original spot on the CD when it gets disturbed. Therefore any strong vibrations or other mechanical shocks will probably destroy the CD you are writing.

If the test cdrecord command works, then run:

  % sudo cdrecord -v dev=0,0,0 <name_of_your_iso_image>

to actually burn the disk.  If you use cdrecord to overwrite a CD-RW, you must add the option "blank=..." to erase the old content. Please read the man page for cdrecord to learn more about the various methods to blank the CD-RW.

Notice that we didn't say to become root, even if you have the ability to do so--  That's because running ANY utility as root if you don't need to is a bad idea. Use sudo; it's a good thing!  If you do not have the appropriate sudo privileges on your system, contact your systems administrator.

After a minute, your system should automount your newly created disk!  If it doesn't, type:

  % mount /mnt/cdrom

or hit the manual eject on the drive, then reload the disk and it should work.


Don't forget to delete the ISO image you created, or you'll be wasting hard drive space.

Other Resources

Questions?

Email Physics Computing Services at pcs@physics.ucsb.edu


Updated September 13, 2004
Physics Computing Services
pcs@physics.ucsb.edu