The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
cdrecord - writing multiple sessions 31 December 2000
Need more help on this topic? Click here
This article has 1 comment
Show me similar articles
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: http://mlug.missouri.edu/~rjudd/projects/cdburning.html 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
      0,12639
    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örg Schilling
[snip]
Blocks total: 336225 Blocks current: 336225 Blocks remaining: 334986
Starting to write CD/DVD at speed 12 in write mode for multi session.
Last chance to quit, starting real write in 1 seconds.
Waiting for reader process to fill input buffer ... input buffer ready.
Performing OPC...
Starting new track at sector: 0
Track 01: 2 of 2 MB written (fifo 100%).
Track 01: Total bytes read/written: 2533376/2533376 (1237 sectors).
Writing time: 23.826s
Fixating...
Fixating time: 23.689s
cdrecord: fifo had 40 puts and 40 gets.
cdrecord: fifo was 0 times empty and 0 times full, min fill was 100%.

Have a quick look at the drive contents:

# mount /cdrom
# ls -l /cdrom
total 2411
-rw-r--r-- 1 dan dan 2469096 Dec 31 11:50 mycvs.2000.12.31.tgz
# umount /cdrom

Find out the where the free space starts:

# cdrecord -msinfo dev=0,5,0
0,12639

Create the second ISO using the free space information from the previous step:

# mkisofs -J -L -R -o freshportsbackup.raw -M /dev/cd0a -C 0,12639 my.backup.2000.12.*
Warning: creating filesystem that does not conform to ISO-9660.

[snip]

52.89% done, estimate finish Sun Dec 31 12:59:18 2000
70.51% done, estimate finish Sun Dec 31 12:59:22 2000
88.17% done, estimate finish Sun Dec 31 12:59:23 2000
Total translation table size: 0
Total rockridge attributes bytes: 1885
Total directory bytes: 0
Path table size(bytes): 10
Max brk space used d164
28369 extents written (55 Mb)

Burn the second ISO:

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

[snip]

Blocks total: 336225 Blocks current: 323586 Blocks remaining: 307854
Starting to write CD/DVD at speed 12 in write mode for multi session.
Last chance to quit, starting real write in 1 seconds.
Waiting for reader process to fill input buffer ... input buffer ready.
Performing OPC...
Starting new track at sector: 12639
Track 02: 30 of 30 MB written (fifo 100%).
Track 02: Total bytes read/written: 32215040/32215040 (15730 sectors).
Writing time: 33.053s
Fixating...
Fixating time: 10.438s
cdrecord: fifo had 508 puts and 508 gets.
cdrecord: fifo was 0 times empty and 361 times full, min fill was 95%.

Have a look at the contents now:

# mount /cdrom
# ls /cdrom
my.backup.2000.12.17.tgz
my.backup.2000.12.18.tgz
my.backup.2000.12.19.tgz
my.backup.2000.12.20.tgz
my.backup.2000.12.21.tgz
my.backup.2000.12.22.tgz
my.backup.2000.12.24.tgz
my.backup.2000.12.25.tgz
my.backup.2000.12.26.tgz
my.backup.2000.12.27.tgz
my.backup.2000.12.28.tgz
my.backup.2000.12.29.tgz
my.backup.2000.12.30.tgz
my.backup.2000.12.31.tgz
mycvs.2000.12.31.tgz
# umount /cdrom


Need more help on this topic? Click here
This article has 1 comment
Show me similar articles