1 Introduction
I've always been curious as to whether my Linux setup would support writing
and reading multi-session CDs. Now I know it does. No surprise really,
but I wasn't able to find a quick guide or HowTo so I thought I'd post
this. I hope you find it useful.
2 Configuration
My CD-R is an HP 7100i CD-Writer Plus connected to a Pentium II system
with 128MB RAM and a 6.4GB main drive. The system is running Redhat GNU-Linux
5.2 kernel 2.0.36 with SCSI emulation compliled in. The CD-R appears to
the system as /dev/scd1, and to cdrecord as dev=1,0.
CDRECORD and MKISOFS are the two tools you will need to make your multi-session
burns. I used cdrecord version 1.8a4 and mkisofs 1.12b4 while writing this
document.
3 Make Initial CD
3.1 Make first image file
The initial step is to make an image file which will be written to the
CD-R as the first session. My preferred command line is:
mkisofs -l -J -L -r -m core -m lost+found -o <outfile> <dir>
The breakdown for this is as follows:
+-------+-------------------------------------------+
|Switch | Description |
+-------+-------------------------------------------+
+-------+-------------------------------------------|
| -l | allow 32 character filenames |
+-------+-------------------------------------------+
| -J | allow Joliet extension for our NT friends |
+-------+-------------------------------------------+
| -L | allow leading periods in filenames |
+-------+-------------------------------------------+
| -r | reset file ownership and mode flags |
+-------+-------------------------------------------+
| -m | disallow the following filename |
+-------+-------------------------------------------+
| -o | filename for output image |
+-------+-------------------------------------------+
| <dir> | directory to read |
+-------+-------------------------------------------+
3.2 Test image file
If the first step proceeded without error, we should
check the image file to make sure it's ok. I use the loopback driver that I have compiled sinto my Linux kernel. The
following command mounts the file.
mount <IMG file > -t iso9660 <mount point> -o loop
Browse the mounted filesystem to be sure the files are fine, then
umount the image file.
3.3 Write image file
Now we're going to do the initial
burn on the cd. My command line for this is:
cdrecord -v -multi -data speed=2 dev=1,0 <img>
The switches are as follows:
+--------+--------------------------------------------------+
| Switch | Description |
+--------+--------------------------------------------------+
+--------+--------------------------------------------------+
| -v | allow increased feedback from cdrecord |
+--------+--------------------------------------------------+
| -multi | set multi-session flag (not for the last session)|
+--------+--------------------------------------------------+
| speed= | write speed of CD_R (2x in example) |
+--------+--------------------------------------------------+
| dev= | SCSI device (1,0 in example) |
+--------+--------------------------------------------------+
| <img> | filename of ISO image |
+--------+--------------------------------------------------+
Use the commands cdrecord -scanbus and cdrecord -inq dev=x,x to obtain
further information about your CD-R.
3.4 Test CD
Mount your freshly burned CD using:
mount /dev/<device name> -t iso9660 <mount point>
Check it for correctness and close it using:
umount <mount point>
4 Add a New Session
Here we will add a new session to the CD we just made. Essentially
we just repeat our first steps, adding some new track number information
to the command lines. This information applies to all sessions written
to the CD except for the first and last session.
4.1 Get Track Information
First we have to obtain the track start and track end data for the previous
session using the command:
cdrecord -msinfo dev=1,0
which will output two numbers. Jot them down because you will need them for our next step. For
our examples I will use the numbers 0,17137.
4.2 Make second image file
Now we run mkisofs with the same options as before but add two new switches
before the -o option:
mkisofs -l -J -L -r -m core -m lost+found -C 0,17137 -M /dev/scd1 -o <outfile> <DIR>
The descriptions for these new command line switches are:
+-------+---------------------------------+
|Switch | Description |
+-------+---------------------------------+
| -C | track info for previous session |
+-------+---------------------------------+
| -M | system device name for CD-R |
+-------+---------------------------------+
Testing the resulting image is difficult. I normally just mount the file
(see 3.2) and then do a df to see if it mounted correctly. Files will not
appear on the mount point. This is normal - we are just testing for the
actual mount itself. Now umount the image and proceed to the next step.
4.3 Write image file
Now we write the second (or later) session to the
CD . The command is identical to our first write (see 3.3).
cdrecord -v -multi -data speed=2 dev=1,0 <IMG>
4.4 Mount the multi-session CD
If everything went well in the last step we mount the CD as normal (see
3.4) and can view the entire filesystem.
5 Final Sessions
5.1 Write final image
To write your final track to the disk simply omit the -multi switch
from the cdrecord command line in step 4.3. This will finalize the disk,
and allow it to be read by other operating systems such as DOS or WinNT
(depending on your mkisofs instructions).
6 Caveats & Notes
6.1 CD Capacity
CD-R media have a maximum capacity of 99 tracks , and ~650 megabytes
of data. No error checking exists in cdrecord (that I'm aware of) to prevent
you from trying to write a track larger than the available free space on
the CD. Measure free space twice before nearing the edge. It may be more
prudent to start a new CD than to risk frying all your previous sessions.
6.2 File Structure
Cdrecord will assume the <DIR> part of any mkisofs command to be the root directory of the target
CD. If you want subdirectories on the CD make sure you have created them
in the <DIR> directory before running mkisofs.
6.3 File Names
Files with the same name - TRANS.TBL for example - will be overwritten by subsequent sessions
containing the same name in the same directory. I assume this same behaviour
applies to directories as well, although I haven't tested this.
6.4 Acknowledgements
CDRECORD is written and maintained by Jorg Schilling. His url is
http://www.fokus.gmd.de/nthp/employees/schilling/cdrecord.html.
MKISOFS is written and maintained by Eric Youngdale. He may be reached at ericy@gnu.ai.mit.edu.
MKISOFS is available at all major ftp sites. Additionally, patched versions are included in selected releases of CDRECORD.
Kudos to both these gentlemen for offering the GNU/Linux community such valuable tools.
Please report any inaccuracies in this document to me at mstolove@home.com.
multisession.html 19990415 v1.0
|