1Creating multi-session CD's Mini Howto FAQ
2
3Multi-session filesystems are a trick that comes from the Kodak photo CD.
4The OS mounts the last session that contains the sum of the current session
5and all previous sessions.
6
7To test (with Linux):
8
9Create a iso-9660 filesystem image with mkisofs-1.10 or later.
10mkisofs is included in the cdrecord release (including
11SunOS/Solaris multi-session support)
12Use the -R flag to add Rock Ridge extensions (this is important).
13
14Assuming that the CD-R drive is connected to target 2 on the SCSI bus.
15
16Write the first session with:
17
18cdrecord -v speed=2 dev=2,0 -eject -multi isoimage.raw
19
20Note that all Sony drives do no support XA2 disks in firmware - read README.sony
21for more information.
22
23This must be a iso9660 image with Rock Ridge extensions (see above)
24
25Note the number of sectors written and check the disk, it should be mountable.
26
27Next step is to check if cdrecord is able to retrieve the following data:
28
29	1) The first block (sector) number in the first track of the last session
30	   This must be '0' in our case.
31
32	2) The next writable address in the unwritten session following the current.
33	   This should be the number of sectors written in the first
34	   run + ~ 11400 sectors for about 22MB lead out/in
35
36	   For the first additional session this is 11250 sectors lead-out/lead-in
37	   overhead + 150 sectors for the pre-gap of the first track after the
38	   lead-in = 11400 sectors.
39
40	   For all further session this is 6750 sectors lead-out/lead-in
41	   overhead + 150 sectors for the pre-gap of the first track after the
42	   lead-in = 6900 sectors.
43
44To get this information type:
45
46cdrecord -msinfo dev=2,0
47
48The output should be two numbers separated by a comma.
49
50	e.g.: 0,204562
51
52The first number is (1), the second number is (2).
53
54Create the image for the next session with mkisofs-1.12 or later.
55It is included in the cdrecord distribution.
56
572nd session:
58You should create a directory that contains a second directory with data in it
59for this purpose.
60
61	e.g.:
62		first_dir/
63			second_dir/
64				file_1
65				file_2
66				...
67
68call:
69
70On Linux:
71mkisofs -o isoimage_2.raw -R  -C xx,yy -M /dev/cdwriter_blk_dev  first_dir
72
73On SunOS:
74mkisofs -o isoimage_2.raw -R  -C xx,yy -M target,lun first_dir
75
76Note that the name "first_dir" is not important.
77
78If you still keep the old raw image of the first session and there is only
79one previous session on the CD you may also call:
80
81mkisofs -o isoimage_2.raw -R  -C xx,yy -M isoimage.raw first_dir
82
83
84The argument of -C is the output of cdrecord -msinfo
85-	On Linux, the argument of -M is a device that would allow you to mount
86	the current CD in the CD-writer
87-	On SunOS, target and lun refer to the SCSI target and lun of the
88	CD-R device with the same notation as for cdrecord dev=xxx,yyy .
89
90
91If you want to check, whether mkisofs make everything right, you should create
92another image by using the following command line.
93
94On Linux:
95mkisofs -o isoimage_2.raw -R  -C xx,0 -M /dev/cdwriter_blk_dev  first_dir
96
97On SunOS:
98mkisofs -o isoimage_2.raw -R  -C xx,0 -M target,lun first_dir
99
100Where xx is the first number of the pair returned by cdrecord -msinfo
101
102You may check ***this** image by mounting it with my "fbk" on Solaris
103or the loopback driver on Linux.
104
105On Linux type:
106	mount isoimage_2.raw -r -t iso9660 -o loop /mnt
107
108On SunOS type:
109	mount -r -F fbk -o type=hsfs /dev/fbk0:isoimage_3.raw /mnt
110
111For Solaris 8 and later you may also use the Sun lofi driver (see README.sun-lofi)
112
113If you list /mnt, you should see all directories that have been in the first
114session and the directory "second_dir". If you try to read a file from the
115first session, you will get an I/O error or bad data (depending on the
116block address), don't worry about that. If you try to read a file from
117the second session, you will see everything correctly.
118
119To write the second session to CD, call:
120
121cdrecord -v speed=2 dev=2,0 -eject -multi isoimage_2.raw
122
123If you mount this CD, you should see the first session and the second directory
124from 2nd session added to the root directory of the CD.
125
126
127Additional check:
128
129call:
130
131cdrecord -msinfo dev=2,0
132
133The first number should be the first writable address which was retrieved by the
134first call to cdrecord -msinfo after creating the first session.
135The second number should be the first number + number of sectors of the second session
136+ ~ 11400 sectors.
137
138Note: The first lead-out is 1:30 (6750 sectors) the lead-in is 1:00 (4500 sectors)
139All following sessions need only 0:30 for lead-out (2250 sectors), the lead-in
140is also 1:00. So in theory, the can be 44 sessions on s 74 minute disk if you
141take into account that the minimum track size is 4 seconds.
142
143The total amount of the overhead is 11250 + 150 sectors for the first additional
144session and 6750 + 150 sectors for all subsequent sessions.
145The 150 additional sectors are the pre-gap sectors for the first track after
146the current session.
147
148Some notes on multi-session CD's that contain only Joliet but no Rock Ridge:
149
150Joliet is a really bad idea in general:
151
152-	There is no way to find a relation between a ISO-9660 name and a Joliet
153	name. If the file has a size, you may try to match the starting sector #
154	but if the size in 0 it's impossible.
155
156
157-	Joliet does not allow long filenames (it limits names to 64 chars).
158
159-	Joliet does not allow all (usually used) characters in filenames.
160
161	All code points between (00)(00) and (00)(1F), inclusive. (Control Characters)
162		(00)(2A) '*'(Asterisk)
163		(00)(2F) '/' (Forward Slash)
164		(00)(3A) ':' (Colon)
165		(00)(3B) ';' (Semicolon)
166		(00)(3F) '?' (Question Mark)
167		(00)(5C) '\' (Backslash)
168
169	While '/' is not a real problem ;-) other characters may cause trouble.
170
171All notes above prevent you from doing reliable multi-session if the CD does
172only contain Joliet but des not contain Rock Ridge attributes.
173
174In addition, please read README.joliet in the mkisofs directory.
175
176This is the answer to a commonly asked question is why can't I continue a
177multisession CD that has been started on a Microsoft system using mkisofs.
178
179
180Note: It is not possible to create a multi-session HFS CD. If you create
181a multi-session CD using any of the HFS options, then each new HFS
182session will ignore HFS files from any previous sessions. A warning will
183be printed if you attempt this. However, if you use the '-part' option to
184mkisofs for each session you create, then each session will appear as
185separate volumes when mounted on a Mac. In this case, it is worth using the
186'-V' or '-hfs-volid' option to give each session a unique volume name,
187otherwise each "volume" will appear on the Desktop with the same name.
188
189
190Joerg Schilling
191