Burning CD, data disk using Command Line Interface with cdrecord ...

Creating an Image

If you are working on servers that don't have a console attached, "mkisofs" and "cdrecord" utilities make working with ISO images very easy!

An ISO is a slang for an image of an ISO9660 filesystem, which is the common format of data CD-ROMs.

To make an ISO image to prepare for burning in a CD burner, use "mkisofs":

$ mkisofs -r /path/to/direcory/ > /tmp/directory.iso

or

$ mkisofs -r -o /tmp/directory.iso /path/to/direcory/

or for DVD video

$ mkisofs -dvd-video -r -V VolumeLabel -o /tmp/directory.iso /path/to/direcory/

The option '-r' sets the permissions of all files to be public readable on the CD and enables RockRidge-extensions. Long filenames and file permissions are preserved when mounted on systems that support Rock Ridge.

The '-V' option assigns the volume ID (volume name or label), this is the name that will be used as the mount point.

Note: You may need "root" priviledges for the below steps.

Testing the CD Image

Before burning the CD, make sure to check that the file size is less than 650 MB, the capacity the CD-R media can hold and also check that the iso image is proper by doing a quick test.

The below command will give the size of the iso file:

#du -hs /tmp/directory.iso

To mount the file directory.iso created above on the directory "/mnt/cdrom", give the command:

#mount -t iso9660 -o ro,loop /tmp/directory.iso /mnt/cdrom

Now you can inspect the files under "/mnt/cdrom". To umount the CD-image:

#umount /mnt/cdrom

Burning the CD Image

Find out which SCSI device your CD-writer is attached to:

cdrecord -scanbus

When ready, the below command should burn an ISO to a CDR:

#cdrecord -v speed=2 dev=0,0,0  -data  /tmp/directory.iso

You should specify the writing speed of your burner or slower in the "speed=" option. If you need to erase a CDRW before burning the ISO, pass the "blank=" parameter:

#cdrecord -v speed=2 dev=0,0,0  blank=fast -data  /tmp/directory.iso

Multi-session CD

If you need to create multi-session CD you must use the option "-multi" for cdrecord as long as you want to add further sessions.

The images for the second and subsequent sessions are a little bit more complicated to generate. Mkisofs must know where the free space on the CD-R begins. That information can be gathered by using the option "-msinfo" on cdrecord.

#mkisofs -R -o /tmp/directory2.iso -C `cdrecord -msinfo dev=0,0,0` -M /dev/cdrom /path/to/directory2/

Then record the iso file using the below command:

#cdrecord -v -eject speed=2 dev=0,0,0 -multi -data  /tmp/directory2.iso

For more information, read the file README.multi, which is distributed with cdrecord.

Further Reading: CD Writing HOWTO available at The Linux Documentation Project.

Comments

Comment viewing options

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

Use genisoimage in recent distros.

Direct cdrecord

Data can be recorded to cd directly without creating iso files if sufficient disk space does not exist:

# mkisofs -r ./data/ | cdrecord -eject -v speed=24 -

Can be first tested using:

# mkisofs -r ./data/ | cdrecord -dummy -eject -v speed=24 -

mkisofs: Unable to make a DVD-Video image -- resolved

I was getting the below error when running mkisofs with the -dvd-video argument passed to it:

# mkisofs -dvd-video -r -o /tmp/movie.iso /tmp/movie/*
mkisofs: Unable to make a DVD-Video image

Found out that mkisofs is looking for a subdirectory named "VIDEO_TS", So the correct command was:

# mkisofs -dvd-video -r -o /tmp/movie.iso /tmp/movie/
Burning CD with Fedora Core 3

I had to burn the CD as root giving ATA as the devicename:

# cdrecord -v speed=24 dev=ATA:1,0,0 -data ./KNOPPIX_V3.7-2004-12-08-EN.iso

Below is what the scanbus looks like:

# cdrecord -scanbus
Cdrecord-Clone 2.01-dvd (i686-pc-linux-gnu) Copyright (C) 1995-2004 Jörg Schilling
Note: This version is an unofficial (modified) version with DVD support
Note: and therefore may have bugs that are not present in the original.
Note: Please send bug reports or support requests to http://bugzilla.redhat.com/bugzilla
Note: The author of cdrecord should not be bothered with problems in this version.
scsidev: 'ATA'
devname: 'ATA'
scsibus: -2 target: -2 lun: -2
Linux sg driver version: 3.5.27
Using libscg version 'schily-0.8'.
cdrecord: Warning: using inofficial libscg transport code version 
(schily - Red Hat-scsi-linux-sg.c-1.83-RH '@(#)scsi-linux-sg.c        
1.83 04/05/20 Copyright 1997 J. Schilling').
scsibus1:
        1,0,0   100) 'HL-DT-ST' 'RW/DVD GCC-4241N' 'A101' 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) *
Comment