Dec 312000

cdrecord – writing multiple sessions

A CD will hold about 650 MB of data.  This doesn’t mean you need to queue your data until you get enough to burn a CD.  You can burn multiple sessions.   Each session must use the -multi flag.  This is from man cdrecord:
-multi Allow multi session CD's  to  be  made.  This  flag
       needs  to  be  present  on  all sessions of a multi
       session disk, except you want to create  a  session
       that  will  be  the last session on the media.  The
       fixation will be done in a way that allows the  CD-
       Recorder  to append additional sessions later.

But it’s not as straight forward as that. There’s a trick.  And I made two coasters before I found out what the trick is.  I found the solution at: which is titled "Notes on CD burning".  It appears to be Linux-specific (in so much as my website is FreeBSD-specific) but it does contain the clues which allowed me to stop making coasters.  At that page, you’ll want to click on Advanced Topics and scroll down until you see Multisession CDs.  This is there I found the solution.

The tricky part is the creation of the ISO images subsequent to the first ISO image.   You can create the first ISO in the regular way.  But with all other ISO images, you need to find out where the free space on the CD starts.  You use this information when creating the new ISO.

The sharp eyed amongst you may notice that the device used in this article differs from that used in the cdrecord – writing your own CDs article.  That’s not magic.  And it’s not a mistake.  When I wrote the first article, I had two SCSI cards in the box.  I’ve since returned one to it’s owner and put the CDRW on the same card as the two SCSI drives.

The steps

NOTE: In this article, I specify the speed which should be used to write to the CD.   You should adjust that value to suit your CD drive.

Here are the steps I used:

  1. Burn the first ISO image:
    mkisofs -J -L -R -o freshportsbackup.raw freshports.backup.2000.12.*
  2. Record that image using the multi and data flags:
    cdrecord -v -multi -data speed=12 dev=0,5,0 freshports.raw

    Remember you may want to should adjust speed to suit your CD drive
  3. Create the second image:
    1. Locate the start of the free space on the CD:

      # cdrecord -msinfo dev=0,5,0
    2. Create the second image using the starting location and specify the CD write device:

      mkisofs -J -L -R -o freshportsbackup.raw -M /dev/cd0a -C 0,12639 freshports.backup.2000.12.*

      Note: /dev/cd0a is my CD writer.
      Note: 0,12639 is obtained during step 3a.
  4. Burn the second ISO image:

    cdrecord -v -multi -data speed=12 dev=0,5,0 freshportsbackup.raw

    Remember you may want to should adjust speed to suit your CD drive.

If you forget which device is your cdwrite, look in /etc/fstab where you should see something like this:

$ grep cd /etc/fstab
/dev/cd0a /cdrom cd9660 ro,noauto 0 0

The examples

This example will show how I first burned some FreshPorts backups and then a cvs repository.  I have snipped some bits from the output.

Create the first ISO:

# mkisofs -J -L -R -o freshports.raw mycvs.2000.12.31.tgz
Warning: creating filesystem that does not conform to ISO-9660.
Total translation table size: 0
Total rockridge attributes bytes: 261
Total directory bytes: 0
Path table size(bytes): 10
Max brk space used c164
1237 extents written (2 Mb)

Burn the first ISO:

# cdrecord -v -multi -data speed=12 dev=0,5,0 freshports.raw
Cdrecord 1.9 (i386-unknown-freebsd4.2) Copyright (C) 1995-2000 J

  One Response to “cdrecord – writing multiple sessions”

  1. Hello,

    I’ve found this article very useful. But…

    Unfortunatelly my server does not have SCSI CD writer – only ATA one. So instead of using cdrecord I use burncd (it is part of FreeBSD contrib). See man 8 burncd for more details, but it’s very easy to substitute cdrecord with burncd:

    burncd -m -v -f /dev/acd0c data /var/db/cdrw/backup20030616.raw fixate

    Krzysztof Stryjek