Writing CDs and DVDs

Most workstations now have a DVD/CD writer drive - here's how to use it.

Software

There are two software options for writing CD and DVD discs - the first is the K3B GUI, which is quite easy to use, and makes things relatively simple. Unfortunately, at the moment the software does not get on at all well with many of the DVD-R drives we have, and can hang the computer. Therefore, for the moment it's safest to use the command line software outlined below!

Writing a CD-R

To write a CD, do the following:
  1. Organise the data to be written to CD. Copy the files to a directory on your scratch area (eg. /scratch/rsir/myfiles/) and arrange them in subdirectories, etc, as desired.
  2. Use the mkisofs command to create an ISO disk image of them:
    cd /scratch/rsir/myfiles
    mkisofs -d -D -l -L -N -r -v -o /scratch/rsir/mycd.iso . 
    
  3. Insert a blank disc into the drive, and then run the cdrecord command:
    cdrecord -dao -eject -speed=SPEED -driveropts=burnproof dev=DEVICE /scratch/rsir/mycd.iso
    
    where SPEED is the write speed (16,24,32,40 are available, depending on the available media, though I don't recommend using over 24X in most cases). DEVICE is usually /dev/cdwriter for the IDE drives - under Enterprise Linux 4 the output from cdrecord -scanbus is not useful. The BURNPROOF feature, activated using the -driveropts=burnproof flag, turns the drive laser off if the machine temporarily can't write to the disk, avoiding a failed burn - you should always use this, since under Enterprise Linux 4 cdrecord cannot get the dedicated real time priority it wants, and cannot guarantee 100% access to the drive at all times.

    The computer will write the CD and eject it when it is ready. Mostly you can ignore warnings about the RR-scheduler.
If in doubt about any aspect of the process then try a test run using the -dummy switch in cdrecord, which will test to see if the burn can be successful, without turning on the laser of the writer.

Writing a DVD-R

Procedures for writing a DVD are pretty much the same as for the CDRs above, only you need to use the -udf flag to make the .ISO image use the UDF format:
mkisofs -d -D -l -L -N -r -v -udf -o /scratch/rsir/mycd.iso .

To write the disc use the cdrecord command to burn. Syntax is basically the same as with CDs. Note that the maximum writing speed for the DVDs we have is 4X-8X, but some of the older drives will only support 2X burning.
cdrecord -eject -dao -speed=2 -driveropts=burnproof dev=DEVICE /scratch/rsir/mycd.iso

Verification

It is important to verify that the disk has burned correctly. The best way to do this is to generate MD5-hash sums for the source and newly burned files, and check for differences. The simplest way to do this is run a checksum for the entire disk, and compare that to the checksum for the ISO image:
md5sum /scratch/rsir/mydvd.iso
4bb7947e1bd5291c5b9e20182e63923e /scratch/rsir/mydvd.iso
md5sum /dev/cdrom
4bb7947e1bd5291c5b9e20182e63923e /dev/cdrom
The checksums should agree for both - if not, there is a problem! Note that you can only run md5sum on the /dev/cdrom device if
  1. you are logged onto the console of the machine
  2. /dev/cdrom is not already mounted
  3. the drive supports the operation properly - many quickly return with an incorrect MD5 sum. Only believe the answer if it takes a few minutes to calculate!
A more reliable option is to mount the disk and run md5sums on each of the individual files on it. The following command will generate an md5sum of each file in the current directory (and all directories below) and write them to a file. These could then be diffed against similar results for the source material.
find . -type f -exec md5sum '{}' ';' > /home/rsir/somemd5s.lis

Last updated Monday September 18, 2006