Home : Linux resources : "Howto" : Burning DVDs and CDs
/dev/sr1 /media/dvd iso9660 noauto,users,ro 0 0
Be sure to create the /media/dvd directory if it does
not already exist. Then, "mount /media/dvd" will put
the drive content there.
[root@rgrjr /root]# cdrecord -scanbus
Cdrecord 1.10 (i586-pc-linux-gnu) Copyright (C) 1995-2001 Jörg Schilling
Linux sg driver version: 2.1.39
Using libscg version 'schily-0.5'
scsibus0:
0,0,0 0) *
0,1,0 1) *
0,2,0 2) *
0,3,0 3) *
0,4,0 4) *
0,5,0 5) 'IOMEGA ' 'ZIP 100 PLUS ' 'J.66' Removable Disk
0,6,0 6) *
0,7,0 7) *
scsibus1:
1,0,0 100) 'HL-DT-ST' 'RW/DVD GCC-4120B' '2.01' 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) *
[root@rgrjr /root]#
The first time I tried this, it only found scsibus0,
which is the symptom of not having the ide-scsi driver
installed for an ATAPI drive.
[root@rgrjr /root]# cdrecord -checkdrive -dev=1,0,0
Cdrecord 1.10 (i586-pc-linux-gnu) Copyright (C) 1995-2001 Jörg Schilling
scsidev: '1,0,0'
scsibus: 1 target: 0 lun: 0
Linux sg driver version: 2.1.39
Using libscg version 'schily-0.5'
Device type : Removable CD-ROM
Version : 0
Response Format: 1
Vendor_info : 'HL-DT-ST'
Identifikation : 'RW/DVD GCC-4120B'
Revision : '2.01'
Device seems to be: Generic mmc CD-RW.
Using generic SCSI-3/mmc CD-R driver (mmc_cdr).
Driver flags : SWABAUDIO
[root@rgrjr /root]#
[The -inq flag gets a subset of this information, mostly
the drive configuration part. -- rgr, 7-Jul-02.]
mkisofs -f -max-iso9660-filenames -relaxed-filenames -P "Bob Rogers" -V 2003Q1a \
-o foo.iso /scratch/backups/2003Q1a/cd/
cdrecord -speed=8 -dev=1,0,0 -data foo.iso
The first command makes an ISO9660 image out of the contents
of an ordinary Linux directory; the second command writes this
image to the drive. It is split up this way into two operations
because the writing must be done in real time; the CPU has to
ensure that the data gets to the CD in time to be written. The
two operations can be pipelined (see the next item), which
eliminates the temp hard drive space usage, but doing them separately
ensures that the image is burned correctly onto the blank
medium.
mkisofs -max-iso9660-filenames -relaxed-filenames -V 2003Q1a /scratch/backups/cd/2003Q1a \
| cdrecord -dev=1,0,0 -speed=8 -
This turns out to be much faster for me than doing the two
steps separately. The reason is that I have only one hard drive, so
making a ISO9660 image file from content on the same hard drive
requires lots of seeks, which are time-consuming.
Usually, both mkisofs and cdrecord need extra instruction on how and whether to write a multi-session CD:
According to the cdrecord man page,
The fixation will be done in a way that allows the CD-Recorder to append additional sessions later. This is done by generating a TOC with a link to the next program area. The CD thus written is not 100% compatible to manufactured CDs.[From the version 1.10 description of "-multi", edited slightly for readability. -- rgr, 20-Oct-02.]
For example, here's a first session being written to a blank CD in the drive at logical address "1,0,0":
mkisofs /scratch/backups/2003Q1a | cdrecord -dev=1,0,0 -speed=8 -multi -
The second and subsequent sessions look like this:
mkisofs -C `cdrecord -dev=1,0,0 -msinfo` -M 1,0,0 /scratch/backups/test \
| cdrecord -dev=1,0,0 -speed=8 -multi -waiti -
To write a final session, use something based on the second
session example but drop the "-multi" option.
First, you need to put the disk in the drive (but don't mount it), and then copy the raw disk image onto a file on the hard drive:
dd if=/dev/sr0 of=/scratch/backups/cd-image.iso9660
You may need to substitute "/dev/sr0" with whatever the
device is named on your system; see above
for hints. Then, mount it wherever you like as an ISO9660 file
system via a "loop device:"
mkdir -p /mnt/cd-image
mount cd-image.iso9660 /mnt/cd-image -t iso9660 -o loop
See the "THE LOOP DEVICE" section of the mount
man page for more details.
to_write_subdir=.
mkisofs_cmd='mkisofs -max-iso9660-filenames -relaxed-filenames -quiet'
disk_size=`$mkisofs_cmd -print-size $to_write_subdir`
$mkisofs_cmd $to_write_subdir \
| cdrecord-wrapper.sh -dao -multi -tsize=${disk_size}s -dev=0,0,0 -
Note that the key thing is to specify -tsize to
cdrecord-wrapper.sh, so you need to run mkisofs
with the -print-size option, ensuring that you use the
exact same options in both places.
cd-dump.pl is a utility that uses mkisofs and
cdrecord to burn directories to CD or DVD. (Despite the
name, they need not be "dump" files.) It is available from Github at
the following link:
cd-dump.pl
The documentation is in the script, and it does not require any additional Perl code beyond what comes with a standard GNU/Linux installation. It can also be installed along with the backup tools in the "scripts" project.
Here is a useful subset of cdrecord options: