DragonFly 3.2 supports the Areca ARC-1882 RAID controller family
[ikiwiki.git] / docs / handbook / handbook-creating-cds.mdwn
1 \r
2 ----\r
3 \r
4 ## 12.5 Creating and Using Optical Media (CDs) \r
5 \r
6 ***Contributed by Mike Meyer. ***\r
7 \r
8 ### 12.5.1 Introduction \r
9 \r
10 CDs have a number of features that differentiate them from conventional disks. Initially, they were not writable by the user. They are designed so that they can be read continuously without delays to move the head between tracks. They are also much easier to transport between systems than similarly sized media were at the time.\r
11 \r
12 CDs do have tracks, but this refers to a section of data to be read continuously and not a physical property of the disk. To produce a CD on DragonFly, you prepare the data files that are going to make up the tracks on the CD, then write the tracks to the CD.\r
13 \r
14 The ISO 9660 file system was designed to deal with these differences. It unfortunately codifies file system limits that were common then. Fortunately, it provides an extension mechanism that allows properly written CDs to exceed those limits while still working with systems that do not support those extensions.\r
15 \r
16 The [`sysutils/mkisofs`](http://pkgsrc.se/sysutils/mkisofs) program is used to produce a data file containing an ISO 9660 file system. It has options that support various extensions, and is described below. It is installed by default.\r
17 \r
18 Which tool to use to burn the CD depends on whether your CD burner is ATAPI or something else. ATAPI CD burners use the `[creating-cds.html#BURNCD burncd]` program that is part of the base system. SCSI and USB CD burners should use `[creating-cds.html#CDRECORD cdrecord]` from the [`sysutils/cdrtools`](http://pkgsrc.se/sysutils/cdrtools) port.\r
19 \r
20 `burncd` has a limited number of supported drives. To find out if a drive is supported, see the [CD-R/RW supported drives](http://www.freebsd.dk/ata/) list.\r
21 \r
22  **Note:** It ispossible to use `[creating-cds.html#CDRECORD cdrecord]` and other tools for SCSI drives on an ATAPI hardware with the [creating-cds.html#ATAPICAM ATAPI/CAM module].\r
23 \r
24 ### 12.5.2 mkisofs \r
25 \r
26 [`sysutils/mkisofs`](http://pkgsrc.se/sysutils/mkisofs) produces an ISO 9660 file system that is an image of a directory tree in the UNIX® file system name space. The simplest usage is:\r
27 \r
28     \r
29     # mkisofs -o `***imagefile.iso***` `***/path/to/tree***`\r
30 \r
31 \r
32 This command will create an `***imagefile.iso***` containing an ISO 9660 file system that is a copy of the tree at `***/path/to/tree***`. In the process, it will map the file names to names that fit the limitations of the standard ISO 9660 file system, and will exclude files that have names uncharacteristic of ISO file systems.\r
33 \r
34 A number of options are available to overcome those restrictions. In particular, `-R` enables the Rock Ridge extensions common to UNIX systems, `-J` enables Joliet extensions used by Microsoft systems, and `-hfs` can be used to create HFS file systems used by Mac OS®.\r
35 \r
36 For CDs that are going to be used only on DragonFly systems, `-U` can be used to disable all filename restrictions. When used with `-R`, it produces a file system image that is identical to the DragonFly tree you started from, though it may violate the ISO 9660 standard in a number of ways.\r
37 \r
38 The last option of general use is `-b`. This is used to specify the location of the boot image for use in producing an ***El Torito*** bootable CD. This option takes an argument which is the path to a boot image from the top of the tree being written to the CD. So, given that `/tmp/myboot` holds a bootable DragonFly system with the boot image in `/tmp/myboot/boot/cdboot`, you could produce the image of an ISO 9660 file system in `/tmp/bootable.iso` like so:\r
39 \r
40     \r
41     # mkisofs -U -R -b boot/cdboot -o /tmp/bootable.iso /tmp/myboot\r
42 \r
43 \r
44 Having done that, if you have `vn` configured in your kernel, you can mount the file system with:\r
45 \r
46     \r
47     # vnconfig -e vn0c /tmp/bootable.iso\r
48     # mount -t cd9660 /dev/vn0c /mnt\r
49 \r
50 \r
51 At which point you can verify that `/mnt` and `/tmp/myboot` are identical.\r
52 \r
53 There are many other options you can use with [`sysutils/mkisofs`](http://pkgsrc.se/sysutils/mkisofs) to fine-tune its behavior. In particular: modifications to an ISO 9660 layout and the creation of Joliet and HFS discs. See the [mkisofs(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#mkisofs&section8&manpath=FreeBSD+Ports) manual page for details.\r
54 \r
55 ### 12.5.3 burncd \r
56 \r
57 If you have an ATAPI CD burner, you can use the `burncd` command to burn an ISO image onto a CD. `burncd` is part of the base system, installed as `/usr/sbin/burncd`. Usage is very simple, as it has few options:\r
58 \r
59     \r
60     # burncd -f `***cddevice***` data `***imagefile.iso***` fixate\r
61 \r
62 \r
63 Will burn a copy of `***imagefile.iso***` on `***cddevice***`. The default device is `/dev/acd0c`. See [burncd(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#burncd&section8) for options to set the write speed, eject the CD after burning, and write audio data.\r
64 \r
65 ### 12.5.4 cdrecord \r
66 \r
67 If you do not have an ATAPI CD burner, you will have to use `cdrecord` to burn your CDs. `cdrecord` is not part of the base system; you must install it from either the port at [`sysutils/cdrtools`](http://pkgsrc.se/sysutils/cdrtools) or the appropriate package. Changes to the base system can cause binary versions of this program to fail, possibly resulting in a ***coaster***. You should therefore either upgrade the port when you upgrade your system.\r
68 \r
69 While `cdrecord` has many options, basic usage is even simpler than `burncd`. Burning an ISO 9660 image is done with:\r
70 \r
71     \r
72     # cdrecord dev=`***device***` `***imagefile.iso***`\r
73 \r
74 \r
75 The tricky part of using `cdrecord` is finding the `dev` to use. To find the proper setting, use the `-scanbus` flag of `cdrecord`, which might produce results like this:\r
76 \r
77     \r
78     # cdrecord -scanbus\r
79     Cdrecord 1.9 (i386-unknown-freebsd4.2) Copyright (C) 1995-2000 Jörg Schilling\r
80     Using libscg version 'schily-0.1'\r
81     scsibus0:\r
82             0,0,0     0) 'SEAGATE ' 'ST39236LW       ' '0004' Disk\r
83             0,1,0     1) 'SEAGATE ' 'ST39173W        ' '5958' Disk\r
84             0,2,0     2) *\r
85             0,3,0     3) 'iomega  ' 'jaz 1GB         ' 'J.86' Removable Disk\r
86             0,4,0     4) 'NEC     ' 'CD-ROM DRIVE:466' '1.26' Removable CD-ROM\r
87             0,5,0     5) *\r
88             0,6,0     6) *\r
89             0,7,0     7) *\r
90     scsibus1:\r
91             1,0,0   100) *\r
92             1,1,0   101) *\r
93             1,2,0   102) *\r
94             1,3,0   103) *\r
95             1,4,0   104) *\r
96             1,5,0   105) 'YAMAHA  ' 'CRW4260         ' '1.0q' Removable CD-ROM\r
97             1,6,0   106) 'ARTEC   ' 'AM12S           ' '1.06' Scanner\r
98             1,7,0   107) *\r
99 \r
100 \r
101 This lists the appropriate `dev` value for the devices on the list. Locate your CD burner, and use the three numbers separated by commas as the value for `dev`. In this case, the CRW device is 1,5,0, so the appropriate input would be `dev#1,5,0`. There are easier ways to specify this value; see [cdrecord(1)](http://leaf.dragonflybsd.org/cgi/web-man?commandcdrecord&section=1&manpath=FreeBSD+Ports) for details. That is also the place to look for information on writing audio tracks, controlling the speed, and other things.\r
102 \r
103 ### 12.5.5 Duplicating Audio CDs \r
104 \r
105 You can duplicate an audio CD by extracting the audio data from the CD to a series of files, and then writing these files to a blank CD. The process is slightly different for ATAPI and SCSI drives.\r
106 \r
107  **SCSI Drives** \r
108 \r
109   1. Use `cdda2wav` to extract the audio.\r
110       \r
111       % cdda2wav -v255 -D2,0 -B -Owav\r
112   \r
113   1. Use `cdrecord` to write the `.wav` files.\r
114       \r
115       % cdrecord -v dev=`***2,0***` -dao -useinfo  *.wav\r
116   \r
117   Make sure that `***2.0***` is set appropriately, as described in [creating-cds.html#CDRECORD Section 12.5.4].\r
118 \r
119  **ATAPI Drives** \r
120 \r
121   1. The ATAPI CD driver makes each track available as `/dev/acd`***d***`t`***nn******, where `***d***` is the drive number, and `***nn***` is the track number written with two decimal digits, prefixed with zero as needed. So the first track on the first disk is `/dev/acd0t01`, the second is `/dev/acd0t02`, the third is `/dev/acd0t03`, and so on.\r
122   Make sure the appropriate files exist in `/dev`.\r
123       \r
124       # cd /dev\r
125       # sh MAKEDEV acd0t99\r
126   \r
127   1. Extract each track using [dd(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#dd&section1). You must also use a specific block size when extracting the files.\r
128       \r
129       # dd if#/dev/acd0t01 oftrack1.cdr bs=2352\r
130       # dd if#/dev/acd0t02 oftrack2.cdr bs=2352\r
131       ...\r
132   \r
133   1. Burn the extracted files to disk using `burncd`. You must specify that these are audio files, and that `burncd` should fixate the disk when finished.\r
134       \r
135       # burncd -f `***/dev/acd0c***` audio track1.cdr track2.cdr `***...***` fixate\r
136   \r
137 \r
138 ### 12.5.6 Duplicating Data CDs \r
139 \r
140 You can copy a data CD to a image file that is functionally equivalent to the image file created with [`sysutils/mkisofs`](http://pkgsrc.se/sysutils/mkisofs), and you can use it to duplicate any data CD. The example given here assumes that your CDROM device is `acd0c`. Substitute your correct CDROM device. A `c` must be appended to the end of the device name to indicate the entire partition or, in the case of CDROMs, the entire disc.\r
141 \r
142     \r
143     # dd if#/dev/acd0c offile.iso bs=2048\r
144 \r
145 \r
146 Now that you have an image, you can burn it to CD as described above.\r
147 \r
148 ### 12.5.7 Using Data CDs \r
149 \r
150 Now that you have created a standard data CDROM, you probably want to mount it and read the data on it. By default, [mount(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#mount&section8) assumes that a file system is of type `ufs`. If you try something like:\r
151 \r
152     \r
153     # mount /dev/cd0 /mnt\r
154 \r
155 \r
156 you will get a complaint about ***`Incorrect super block`***, and no mount. The CDROM is not a `UFS` file system, so attempts to mount it as such will fail. You just need to tell [mount(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#mount&section8) that the file system is of type `ISO9660`, and everything will work. You do this by specifying the `-t cd9660` option [mount(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=mount&section=8). For example, if you want to mount the CDROM device, `/dev/cd0`, under `/mnt`, you would execute:\r
157 \r
158     \r
159     # mount -t cd9660 /dev/cd0 /mnt\r
160 \r
161 \r
162 Note that your device name (`/dev/cd0` in this example) could be different, depending on the interface your CDROM uses. Also, the `-t cd9660` option just executes [mount_cd9660(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#mount_cd9660&section8). The above example could be shortened to:\r
163 \r
164     \r
165     # mount_cd9660 /dev/cd0 /mnt\r
166 \r
167 \r
168 You can generally use data CDROMs from any vendor in this way. Disks with certain ISO 9660 extensions might behave oddly, however. For example, Joliet disks store all filenames in two-byte Unicode characters. The DragonFly kernel does not speak Unicode (yet!), so non-English characters show up as question marks. (The CD9660 driver includes hooks to load an appropriate Unicode conversion table on the fly. Modules for some of the common encodings are available via the [`sysutils/cd9660_unicode`](http://pkgsrc.se/sysutils/cd9660_unicode) port.)\r
169 \r
170 Occasionally, you might get ***`Device not configured`*** when trying to mount a CDROM. This usually means that the CDROM drive thinks that there is no disk in the tray, or that the drive is not visible on the bus. It can take a couple of seconds for a CDROM drive to realize that it has been fed, so be patient.\r
171 \r
172 Sometimes, a SCSI CDROM may be missed because it did not have enough time to answer the bus reset. If you have a SCSI CDROM please add the following option to your kernel configuration and [kernelconfig-building.html rebuild your kernel].\r
173 \r
174     \r
175     options SCSI_DELAY=15000\r
176 \r
177 \r
178 This tells your SCSI bus to pause 15 seconds during boot, to give your CDROM drive every possible chance to answer the bus reset.\r
179 \r
180 ### 12.5.8 Burning Raw Data CDs \r
181 \r
182 You can choose to burn a file directly to CD, without creating an ISO 9660 file system. Some people do this for backup purposes. This runs more quickly than burning a standard CD:\r
183 \r
184     \r
185     # burncd -f /dev/acd1 -s 12 data archive.tar.gz fixate\r
186 \r
187 \r
188 In order to retrieve the data burned to such a CD, you must read data from the raw device node:\r
189 \r
190     \r
191     # tar xzvf /dev/acd1\r
192 \r
193 \r
194 You cannot mount this disk as you would a normal CDROM. Such a CDROM cannot be read under any operating system except DragonFly. If you want to be able to mount the CD, or share data with another operating system, you must use [`sysutils/mkisofs`](http://pkgsrc.se/sysutils/mkisofs) as described above.\r
195 \r
196 ### 12.5.9 Using the ATAPI/CAM Driver \r
197 \r
198 ***Contributed by Marc Fonvieille. ***\r
199 \r
200 This driver allows ATAPI devices (CD-ROM, CD-RW, DVD drives etc...) to be accessed through the SCSI subsystem, and so allows the use of applications like [`sysutils/cdrdao`](http://pkgsrc.se/sysutils/cdrdao) or [cdrecord(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#cdrecord&section1&manpath=FreeBSD+Ports).\r
201 \r
202 To use this driver, you will need to add the following lines to your kernel configuration file:\r
203 \r
204     \r
205     device atapicam\r
206     device scbus\r
207     device cd\r
208     device pass\r
209 \r
210 \r
211 You also need the following line in your kernel configuration file:\r
212 \r
213     \r
214     device ata\r
215 \r
216 \r
217 which should already be present.\r
218 \r
219 Then rebuild, install your new kernel, and reboot your machine. During the boot process, your burner should show up, like so:\r
220 \r
221     \r
222     acd0: CD-RW <MATSHITA CD-RW/DVD-ROM UJDA740> at ata1-master PIO4\r
223     cd0 at ata1 bus 0 target 0 lun 0\r
224     cd0: <MATSHITA CDRW/DVD UJDA740 1.00> Removable CD-ROM SCSI-0 device\r
225     cd0: 16.000MB/s transfers\r
226     cd0: Attempt to query device size failed: NOT READY, Medium not present - tray closed\r
227 \r
228 \r
229 The drive could now be accessed via the `/dev/cd0` device name, for example to mount a CD-ROM on `/mnt`, just type the following:\r
230 \r
231     \r
232     # mount -t cd9660 `***/dev/cd0***` /mnt\r
233 \r
234 \r
235 As `root`, you can run the following command to get the SCSI address of the burner:\r
236 \r
237     \r
238     # camcontrol devlist\r
239     <MATSHITA CDRW/DVD UJDA740 1.00>   at scbus1 target 0 lun 0 (pass0,cd0)\r
240 \r
241 \r
242 So `1,0,0` will be the SCSI address to use with [cdrecord(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#cdrecord&section1&manpath=FreeBSD+Ports) and other SCSI application.\r
243 \r
244 For more information about ATAPI/CAM and SCSI system, refer to the [atapicam(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#atapicam&section4) and [cam(4)](http://leaf.dragonflybsd.org/cgi/web-man?command=cam&section=4) manual pages.\r
245 \r
246 ----\r
247 \r
248 \r