home *** CD-ROM | disk | FTP | other *** search
/ Linux 68k 2000 / Linux 68k 2000.iso / dokus / CD-Writing-HOWTO < prev    next >
Encoding:
Text File  |  1997-08-11  |  33.2 KB  |  885 lines

  1.   CD-Writing HOWTO
  2.   Winfried Trⁿmper <winni@xpilot.org>
  3.   v2.0, 10 August 1997
  4.  
  5.   This document deals with the process of writing CDs under Linux.
  6.  
  7.   1.  Introduction
  8.  
  9.   My first experience with CD Writers was guided by the "Linux CD Writer
  10.   mini-HOWTO" by Matt Cutts <cutts@ms.uky.edu>.  Thanks Matt!
  11.  
  12.   Although my intention was only to upgrade his document, I rewrote it
  13.   from the scratch after I realized how much changed since 1994.
  14.  
  15.   1.1.  Disclaimer
  16.  
  17.   I (Winfried Truemper) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  18.   DOCUMENT, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  19.   FITNESS FOR A CERTAIN PURPOSE; IN NO EVENT SHALL I BE LIABLE FOR ANY
  20.   SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  21.   RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  22.   CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  23.   CONNECTION WITH THE USE OF THIS DOCUMENT.  Short: read and use at your
  24.   own risk.
  25.  
  26.   1.2.  Suggested readings
  27.  
  28.   The CD-R FAQ <http://www.cd-info.com/CDIC/Technology/CD-R/FAQ.html> is
  29.   a general FAQ about compact-disk recordables (CD-R).
  30.  
  31.   The Linux CD-ROM HOWTO explains everything one should know about CD-
  32.   ROM drives under Linux. As a supplement, you may want to take a look
  33.   at the Linux SCSI HOWTO and the Linux Kernel HOWTO.
  34.  
  35.   1.3.  Terminology ... lasers at maximum ... fire!
  36.  
  37.   CD-ROM stands for Compact Disc Read Only Memory, a storage medium
  38.   utilizing an optical laser to sense microscopic pits on a silver
  39.   shimmering disk. (The silver shimmering comes from an aluminized layer
  40.   which is the carrier.) The pits represent the bits of the information
  41.   (in some way) and are so petite that some billions of them fit on the
  42.   disc. Thus a CD is a mass-storage medium.
  43.  
  44.   The Term CD-R is a short form of CD-ROM recordable and refers to a CD
  45.   that doesn't have those "microscopic pits" on it's surface
  46.  
  47.   Instead of the aluminium layer (silver) it has a special film
  48.   (colored) into which "microscopic pits" can be burned in. This is done
  49.   by giving the laser which normally only senses the pits a little bit
  50.   more power so he burns the pits. This action can only be taken once on
  51.   a CD-R.
  52.  
  53.   You can leave out some areas for later writing, though, creating a so
  54.   called multi-session CD.
  55.  
  56.   This mini-HOWTO deals with the task of writing a CD-R.  Welcome on
  57.   board, captain.
  58.  
  59.   1.4.  Supported CD-Writers
  60.  
  61.   The detailed list of models which have been reported (not) to work
  62.   successfully is available from
  63.  
  64.        <http://www.shop.de/cgi-bin/winni/lsc.pl>
  65.  
  66.   The list will be included in future versions of this mini-HOWTO.
  67.  
  68.   If your hardware isn't supported you can still use Linux to create an
  69.   image of the later CD but then you have to use DOS-Software to write
  70.   the image to the CD-R. You may wish to do so because most DOS-software
  71.   cannot deal with long filenames available in Linux.
  72.  
  73.   In this case you can skip all hardware-related sections (those about
  74.   generic SCSI devices and cdwrite).
  75.  
  76.   1.5.  Supported "features"
  77.  
  78.   Currently the software for burning CDs under Linux does support the
  79.   following main features:
  80.  
  81.        Feature         cdwrite-2.0     cdrecord-1.5
  82.        --------------------------------------------
  83.        Multisession    only partial    yes
  84.  
  85.        RockRidge       yes (mkisofs)   yes (mkisofs)
  86.        El Torito       yes (mkisofs)   yes (mkisofs)
  87.  
  88.   RockRidge is an extension to allow longer filenames and a deeper
  89.   directory hierarchy. El Torito can be used to produce bootable CDs.
  90.   Please see the accompanied documentation for further details upon this
  91.   special features.
  92.  
  93.   Section 2.8 lists the availability of the mentioned software.
  94.  
  95.   1.6.  Mailinglists
  96.  
  97.   If you want to join the development team (with the intention to
  98.   actively _help_ them), send e-mail to
  99.  
  100.        cdwrite-request@pixar.com
  101.  
  102.   and put the word subscribe in body of the message.
  103.  
  104.   1.7.  Availability
  105.  
  106.   The newest version of this document is always available from
  107.  
  108.        <http://www.shop.de/~winni/linux/cdr/>
  109.  
  110.   2.  Prepare your Linux-box for writing CD-ROMs
  111.  
  112.   2.1.  Set up the hardware
  113.  
  114.   Shut down your computer, switch it off and hook CD writer to the SCSI-
  115.   bus.
  116.  
  117.   Make sure the SCSI-bus is properly terminated and choose a free SCSI-
  118.   ID for the writer. Look at the Linux SCSI-HOWTO if you're not sure. If
  119.   you're completly clueless, ask an expert.
  120.  
  121.   Switch the power on again and check the messages that the BIOS of the
  122.   SCSI-controller prints immediatly after switching the power on.  If it
  123.   doesn't recognize you writer, go back to step (b).  You should see a
  124.   message like
  125.  
  126.   missing picture; has anyone a screenshot of it?
  127.  
  128.   2.2.  A note on writing CDs under Linux
  129.  
  130.   In contrast to other rumors, the Linux-kernel does _not_ require a
  131.   patch in order to write to CDs. Although the file drivers/scsi/scsi.c
  132.   from the kernel-sources contains the lines
  133.  
  134.        case TYPE_WORM:
  135.        case TYPE_ROM:
  136.         SDpnt->writeable = 0;
  137.  
  138.   this does only mean that that CDs and WORMs are not writeable through
  139.   the standard-devices /dev/sda-/dev/sdh - which is ok.
  140.  
  141.   Instead of using these devices the writing of CDs is done through the
  142.   so called generic SCSI-devices which permit nearly everything - even
  143.   writing to CDs.
  144.  
  145.   2.3.  Create the generic devices
  146.  
  147.   The Linux SCSI-HOWTO says about generic SCSI-devices:
  148.  
  149.        The Generic SCSI device driver provides an interface for
  150.        sending SCSI commands to all SCSI devices - disks, tapes,
  151.        CDROMs, media changer robots, etc.
  152.  
  153.   Speaking of the generic devices as interfaces means that they provide
  154.   an alternate way of accessing SCSI-hardware than through the standard
  155.   devices.
  156.  
  157.   This alternate way is required because the standard devices are
  158.   designed to read data block-wise from a disk, tape or cd-rom. Compared
  159.   to this, driving a cd-writer (or a scanner) is more exotic, e.g
  160.   commands to position the laser must be transmitted. To have a clean
  161.   (and therefore fast) implementation of standard-devices, all such
  162.   exotic actions must be done through the generic scsi devices.
  163.  
  164.   As everthing can be done to SCSI-hardware through the generic devices
  165.   they are not fixed to a certain purpose - therefore the name generic.
  166.  
  167.   Goto the /dev-directory and check for generic scsi devices; ls-command
  168.   should show sga-sgh:
  169.  
  170.        bash> cd /dev
  171.        bash> ls -l sg*
  172.        crw-------   1 root   sys     21,   0 Jan  1  1970 sga
  173.        crw-------   1 root   sys     21,   1 Jan  1  1970 sgb
  174.        crw-------   1 root   sys     21,   2 Jan  1  1970 sgc
  175.        crw-------   1 root   sys     21,   3 Jan  1  1970 sgd
  176.        crw-------   1 root   sys     21,   4 Jan  1  1970 sge
  177.        crw-------   1 root   sys     21,   5 Jan  1  1970 sgf
  178.        crw-------   1 root   sys     21,   6 Jan  1  1970 sgg
  179.        crw-------   1 root   sys     21,   7 Jan  1  1970 sgh
  180.  
  181.   If you don't have those device-files then create them by using the
  182.   /dev/MAKEDEV-script:
  183.  
  184.        bash> cd /dev/
  185.        bash> ./MAKEDEV sg
  186.  
  187.   Now the device-files should show up.
  188.  
  189.   2.4.  Enable usage of the generic scsi and loopback devices
  190.  
  191.   The Linux-kernel needs a module that lends it the ability to deal with
  192.   generic scsi devices.  If your running kernel has this feature, it
  193.   should be listed in the pseudo-file /proc/devices:
  194.  
  195.        bash> cat /proc/devices
  196.        Character devices:
  197.         1 mem
  198.         2 pty
  199.         3 ttyp
  200.         4 ttyp
  201.         5 cua
  202.         7 vcs
  203.        21 sg          <----- stands for "Scsi Generic device"
  204.  
  205.        30 socksys
  206.  
  207.        Block devices:
  208.         2 fd
  209.         7 loop        <----- we even can use the loop-devices
  210.         8 sd
  211.        11 sr          <----- stands for "Scsi cd-Rom"
  212.  
  213.   Maybe you have to issue the commands insmod sg, insmod loop or insmod
  214.   sr_mod to load the modules into the kernel. Check again after you've
  215.   tried this.
  216.  
  217.   If one of them doesn't succeed, you must re-configure your kernel and
  218.   re-compile it.
  219.  
  220.        bash> cd /usr/src/linux
  221.        bash> make config
  222.  
  223.        [..]
  224.        *
  225.        * Additional Block Devices
  226.        *
  227.        Loopback device support (CONFIG_BLK_DEV_LOOP) [M/n/y/?] M
  228.  
  229.        [..]
  230.        *
  231.        * SCSI support
  232.        *
  233.        SCSI support (CONFIG_SCSI) [Y/m/n/?]
  234.        *
  235.        * SCSI support type (disk, tape, CD-ROM)
  236.        *
  237.        SCSI disk support (CONFIG_BLK_DEV_SD) [Y/m/n/?] Y
  238.        SCSI tape support (CONFIG_CHR_DEV_ST) [M/n/y/?] M
  239.        SCSI CD-ROM support (CONFIG_BLK_DEV_SR) [M/n/y/?] M
  240.        SCSI generic support (CONFIG_CHR_DEV_SG) [M/n/y/?] M
  241.  
  242.        [..]
  243.        ISO9660 cdrom filesystem (CONFIG_ISO9660_FS) [Y/m/n/?] M
  244.  
  245.   Please note that I omitted the not-so-important questions.
  246.  
  247.   2.5.  Build and install the kernel
  248.  
  249.   If you have questions regarding to this the Linux Kernel-HOWTO is the
  250.   suggested reading. Furthermore your Linux-distribution should ship
  251.   with some documentation about this issue.
  252.  
  253.   Hint: while re-compiling, you can continue with steps 2.7-2.9
  254.  
  255.   2.6.  Reboot the computer for the changes to take effect.
  256.  
  257.   Don't panic if the Linux-kernel prints the messages faster than you
  258.   can read them, at least the initialization of SCSI-devices can be re-
  259.   displayed with the command dmesg:
  260.  
  261.   scsi0 : NCR53c{7,8}xx (rel 17)
  262.   scsi : 1 host.
  263.   scsi0 : target 0 accepting period 100ns offset 8 10.00MHz
  264.   scsi0 : setting target 0 to period 100ns offset 8 10.00MHz
  265.  
  266.     Vendor: FUJITSU   Model: M1606S-512        Rev: 6226
  267.     Type:   Direct-Access                      ANSI SCSI
  268.   Detected scsi disk sda at scsi0, channel 0, id 0, lun 0
  269.  
  270.     Vendor: NEC       Model: CD-ROM DRIVE:84   Rev:  1.0a
  271.     Type:   CD-ROM                             ANSI SCSI
  272.   Detected scsi CD-ROM sr0 at scsi0, channel 0, id 4, lun 0
  273.  
  274.   scsi : detected 1 SCSI disk total.
  275.   SCSI device sda: hdwr sector= 512 bytes. Sectors= 2131992
  276.  
  277.   Shown above is only that part of the initialization-messages that
  278.   report the detection of physically present SCSI-devices.
  279.  
  280.   2.7.  Create loopback devices
  281.  
  282.   Goto the /dev-directory and check for loopback devices.  It's not
  283.   critical if you don't have those devices, but it's convenient if you
  284.   do (see 3.5).  If you already have them, the ls-command should show
  285.   loop0-loop7:
  286.  
  287.        bash> cd /dev
  288.        bash> ls -l loop*
  289.        brw-rw----   1 root  disk    7,   0 Sep 23 17:15 loop0
  290.        brw-rw----   1 root  disk    7,   1 Sep 23 17:15 loop1
  291.        brw-rw----   1 root  disk    7,   2 Sep 23 17:15 loop2
  292.        brw-rw----   1 root  disk    7,   3 Sep 23 17:15 loop3
  293.        brw-rw----   1 root  disk    7,   4 Sep 23 17:15 loop4
  294.        brw-rw----   1 root  disk    7,   5 Sep 23 17:15 loop5
  295.        brw-rw----   1 root  disk    7,   6 Sep 23 17:15 loop6
  296.        brw-rw----   1 root  disk    7,   7 Sep 23 17:15 loop7
  297.  
  298.   If you don't have those device-files, then create them by using the
  299.   /dev/MAKEDEV-script:
  300.  
  301.        bash> cd /dev/
  302.        bash> ./MAKEDEV loop
  303.  
  304.   The last command only succeeds if you have the loop-module in your
  305.   kernel (see 2.4 for handling of modules). If insmod loop does not
  306.   help, you must wait until the new kernel is properly installed (see
  307.   2.5).
  308.  
  309.   2.8.  Get the user-software for burning CDs
  310.  
  311.   2.8.1.  Command line utilities
  312.  
  313.   The following package is required to generate prototypes of CD-Rs:
  314.  
  315.        <ftp://tsx-11.mit.edu/pub/linux/packages/mkisofs/mkisofs-1.11.tar.gz>
  316.  
  317.   Depending on the model of your cd-writer (see 1.3), one of the
  318.   following software for writing prototypes to CD-Rs is required:
  319.  
  320.        <ftp://sunsite.unc.edu/pub/Linux/utils/disk-
  321.        management/cdwrite-2.0.tar.gz>
  322.  
  323.        <ftp://ftp.fokus.gmd.de/pub/unix/cdrecord/cdrecord.tar.gz>
  324.  
  325.   Please use the nearest mirrors of these ftp-Servers or get them from a
  326.   CD.
  327.  
  328.   Be absolutly sure you have version 2.0 of cdwrite or newer.  No older
  329.   version and especially no beta-versions will work properly! Don't
  330.   trust the man-page of (old) mkisofs which states you need version 1.5
  331.   of cdwrite.
  332.  
  333.   For information about ports of cdwrite to Irix and AIX visit the URL
  334.  
  335.        <http://lidar.ssec.wisc.edu/~forrest/>
  336.  
  337.   The Debian-Distribution ships with a patch for release 1.05 of mkisofs
  338.   that adds the option '-K' to it (see 3.4); it's available from
  339.  
  340.        <ftp://ftp.debian.org/pub/debian/rex/source/misc/mkisofs_1.05-3.diff.gz>
  341.  
  342.   This patch is only necassary if you want to mount the CD-image via the
  343.   loopback-device (see 3.5.).
  344.  
  345.   A fix for scsi.c (kernel) to make this patch superfluous was written
  346.   by Eric Youngdale and will be included in the next stable release of
  347.   the Linux kernel.
  348.  
  349.   2.8.2.  A graphical user interface (optional)
  350.  
  351.   X-CD-Roast is full X based CD-Writer-Program, and it is the successor
  352.   of the cdwtools-0.93. It's available from
  353.  
  354.        <http://www.fh-
  355.        muenchen.de/home/ze/rz/services/projects/xcdroast/e_overview.html>
  356.  
  357.   Currently X-CD-Roast is based on a patched version of cdwrite-2.0 and
  358.   thus comes with exactly the same features (see 1.4). Future versions
  359.   may be based on the alternate cdrecord software.
  360.  
  361.   3.  Emperor nero about burning his own classic-CDs [AD64; he misunder¡
  362.   stand it completly] If to smoke you turn I shall not cease to fiddle
  363.   while you burn."
  364.  
  365.   Usally the writing of a CD under Linux is done in 2 steps:
  366.  
  367.   ╖  packaging the desired software into one big file using the mkisofs-
  368.      utility
  369.  
  370.   ╖  writing the big file to the CD-R with cdwrite or cdrecord
  371.  
  372.   It also possible to combine the 2 steps into one via a pipe but that
  373.   is discouraged because it's not reliable. See below.
  374.  
  375.   3.1.  Determine which generic scsi device the writer is attached to
  376.  
  377.   Please note: the current scheme for naming scsi devices under Linux is
  378.   unnecessary complicated and not reliable enough.  The fact that I
  379.   describe it in greater detail here should not be misinterpreted as a
  380.   confirmation of this scheme.
  381.  
  382.   After following all steps of the second chapter your system should be
  383.   able to deal with the task of writing CDs. This section can be used as
  384.   a proof that everything works as intended.
  385.  
  386.   Issue the command dmesg. It should report the messages of the Linux-
  387.   kernel including those printed while booting (limitation: only the
  388.   last 200) and contain some information about the CD-Writer connected
  389.   to the SCSI-bus.
  390.  
  391.   Simple example:
  392.  
  393.          Vendor: YAMAHA  Model: CDR100       Rev: 1.11
  394.          Type:   WORM                        ANSI SCSI revision: 02
  395.        Detected scsi CD-ROM sr1 at scsi0, channel 0, id 3, lun 0
  396.  
  397.   This machine has 4 SCSI-devices connected to it (you can't see it so I
  398.   tell you), with SCSI-id's from 0 to 3. The writer is the 4th
  399.   physically present SCSI-device and therefore connected to /dev/sgd
  400.   (the fourth generic SCSI-device when counting is started with the
  401.   letter a).  In this case the command
  402.  
  403.        cdwrite  --eject  --device /dev/sgd
  404.  
  405.   opens the tray and is a test if everything is set up properly. A more
  406.   complicated example:
  407.  
  408.   scsi0 : AdvanSys SCSI 1.5: ISA (240 CDB)
  409.   scsi1 : Adaptec 1542
  410.   scsi : 2 hosts.
  411.  
  412.     Vendor: HP      Model: C4324/C4325  Rev: 1.20
  413.     Type:   CD-ROM                      ANSI SCSI revision: 02
  414.   Detected scsi CD-ROM sr0 at scsi0, channel 0, id 2, lun 0
  415.  
  416.     Vendor: IBM     Model: DPES-31080   Rev: S31Q
  417.     Type:   Direct-Access               ANSI SCSI revision: 02
  418.   Detected scsi disk sda at scsi1, channel 0, id 0, lun 0
  419.  
  420.   scsi : detected 1 SCSI cdrom 1 SCSI disk total.
  421.   SCSI device sda: hdwr sector= 512 bytes.
  422.  
  423.   In this example two SCSI-controllers host 1 SCSI-device each.  What a
  424.   waste (they are able to host up to 7 devices each). It's not my setup
  425.   so stop asking if I have too much money ...  Anyway for the purpose of
  426.   being an overlookable example this setup is just excellent. :-)
  427.  
  428.   In the above example the CD-Writer has SCSI-id 2 but it is associated
  429.   with the first generic SCSI-device /dev/sga because it's the first
  430.   physically present SCSI-device which Linux has detected.  Hopefully
  431.   this shows clearly that the SCSI-id of a device has nothing to do with
  432.   the associated generic device.
  433.  
  434.   Two questions are left: what happens if you catch the wrong device?
  435.   If you neither specify the option "--<MANUFACTURER>" nor write any
  436.   data to the device, usally a warning message is printed and nothing
  437.   bad happens:
  438.  
  439.        bash> cdwrite  --eject  --device /dev/sgb
  440.  
  441.        Unknown CD-Writer; if this model is compatible with any
  442.        supported type, please use the appropriate command line
  443.        flag.
  444.  
  445.        Manufacturer:  IBM
  446.        Model:         DPES-31080
  447.        Revision:      S31Q
  448.  
  449.   In this case the device /dev/sbg is a scsi harddisk (from IBM).
  450.  
  451.   If you write data to the wrong device, you overwrite the original
  452.   content of it and probably irrecoverable damage your system. Be
  453.   careful, it already happened to me by accident.
  454.  
  455.   3.2.  Collect software
  456.  
  457.   Usally this takes up longer than one expects. Remember that missing
  458.   files cannot be added once the CD is written. :-)
  459.  
  460.   Also keep in mind that a certain amount of the free space of a CD is
  461.   used for storing the information of the iso9660-filesystem (usally a
  462.   few MB).
  463.  
  464.   3.3.  Storing data on a CD.
  465.  
  466.   The term iso9660 refers to the format in which data is organised on
  467.   the CD. To be more precise: it's the filesystem on the CD.
  468.  
  469.   Of course the appearance of files stored in this format is unified by
  470.   the Linux-kernel as for every other filesystem, too.  So if you mount
  471.   a CD into the directory tree, you cannot distinguish it's files from
  472.   other files (The mechanism used to unify the appearance of files is
  473.   called virtual filesystem, short VFS.)
  474.  
  475.   The features of the iso9660 filesystem are not so rich compared to
  476.   those of the extended-2 filesystem which is normally used under Linux.
  477.   On the other hand, the CD is only writable once and some features make
  478.   no sense anyway.  The limitations of the iso9660-filesystem are:
  479.  
  480.   ╖  only 8 levels of sub-directories allowed (counted from the top-
  481.      level directory of the CD) use RockRidge Extensions to enlarge this
  482.      number
  483.  
  484.   ╖  maximum length for filenames: 32 characters
  485.  
  486.   ╖  650 MB capacity
  487.  
  488.   3.4.  Create an iso9660 filesystem
  489.  
  490.   Before any storage medium (e.g. floppy disk, harddisk or CD) can be
  491.   used, it must get a filesystem (DOS speak: get formatted).  This
  492.   filesystem is responsible for organising and incorporating the files
  493.   that should be stored on the medium.
  494.  
  495.   Well, a writable CD is only writable _once_ so if we would write an
  496.   empty filesystem to it, it would get formated - but remain completely
  497.   empty forever. :-)
  498.  
  499.   So what we need is a tool that creates the filesystem while copying
  500.   the files to the CD. This tool is called mkisofs.  A sample usage
  501.   looks as follows:
  502.  
  503.        mkisofs  -r -K  -o cd_image   private_collection/
  504.                        `---------'   `-----------------'
  505.                             |               |
  506.                    write output to   take directory as input
  507.  
  508.   The option '-r' sets the permissions of all files to be public
  509.   readable on the CD and enables Rock Ridge extensions. That is what one
  510.   usually wants and use of this option is recommended until you know
  511.   what you're doing (hint: without '-r' the mount-point gets the
  512.   permissions of private_collection!).  The option '-K' fixes a bug in
  513.   the Linux kernel and prevents the last file on the CD from being
  514.   "destroyed" (not really, but Linux can't read it). You need the
  515.   patched version of mkisofs for it.  This option is equivalent to the
  516.   option '-P' of cdwrite.  Please see the manual-page of mkisofs for
  517.   details.
  518.   mkisofs will try to map all filenames to the 8.3-format used by DOS to
  519.   ensure highest possible compatibility. In case of naming conflicts
  520.   (different files have the same 8.3-name), numbers are used in the
  521.   filenames and information about the chosen filename is printed via
  522.   stderr (usually the screen).
  523.  
  524.   DON'T PANIC:
  525.  
  526.        Under Linux you will never see these 8.3 filenames because
  527.        Linux makes use of the Rock Ridge extensions which contain
  528.        the original file-information (permissions, filename, etc.).
  529.  
  530.   Now you may wonder why the output of mkisofs is not directly sent to
  531.   the writer-device. This has two reasons:
  532.  
  533.   ╖  mkisofs knows nothing about driving CD-writers (see section 2.3.)
  534.  
  535.   ╖  It would not be reliable (see section 4.)
  536.  
  537.   Because the timing of the CD-writer is a critical point, we don't feed
  538.   it directly from mkisofs (remember Linux is not a real-time operating
  539.   system and tasks can be timed badly).  Instead it is recommended to
  540.   store the output of mkisofs in a separate file on the harddisk.  This
  541.   file is then an 1:1-image of the later CD and is actually written to
  542.   the CD with the tool cdwrite in a second step.
  543.  
  544.   The 1:1-image gets stored in a huge file so you need the same amount
  545.   of free disk space that your collected software already eats up.
  546.   That's a drawback.
  547.  
  548.   One could think of creating an extra partition for that and writing
  549.   the image to that partition instead to a file. I vote against such a
  550.   strategy because if you write to the wrong partition (due to a typo),
  551.   you can lose your complete Linux-system.  Furthermore, it's a waste of
  552.   disk-space because the CD-image is temporary data that can be deleted
  553.   after writing the CD.
  554.  
  555.   3.5.  Test the CD-image
  556.  
  557.   Linux has the ability to mount files as if they were disk-partitions.
  558.   This feature is useful to check the directory layout of the CD-image
  559.   is ok. To mount the file cd_image created above on the directory
  560.   /cdrom, give the command
  561.  
  562.        mount -t iso9660 -o ro,loop=/dev/loop0 cd_image /cdrom
  563.  
  564.   Now you can inspect the files under /cdrom - they appear exactly as
  565.   they were on a real CD. To umount the CD-image, just say umount
  566.   /cdrom.  Warning: If you did not use the option '-K' for mkisofs then
  567.   the last file on /cdrom may not be fully readable.
  568.  
  569.   Note:
  570.  
  571.        some ancient versions of mount are not able to deal with
  572.        loopback-devices. If you have such an old version of mount
  573.        it is a hint to upgrade your Linux-system.
  574.   Several people already suggested to put information about
  575.   how to get the newest mount-utilities into this mini-HOWTO.
  576.   I always refuse this.  If your Linux-Distribution ships with
  577.   an ancient mount: report it as a bug.  If your Linux-
  578.   Distribution is not easily upgradable: report it as a bug.
  579.  
  580.   If I included all the information that is necessary to work
  581.   around bugs in bad designed Linux-Distributions, this mini-
  582.   HOWTO would be a lot bigger and harder to read.
  583.  
  584.   3.6.  Remarks on the blank CD-Recordable discs
  585.  
  586.   The german computer magazine "c't" has a list of tips regarding the
  587.   blank CDs in their november 1996 issue:
  588.  
  589.   ╖  "no-name" discs are generally not of highest quality and should
  590.      better not be used
  591.  
  592.   ╖  if a recordable CD is defective, this is likely to apply to the
  593.      whole batch (if you bought more than one at a time); maybe you are
  594.      lucky and can at least use the first 500MB of such CDs ...
  595.  
  596.   ╖  don't touch the CDs at their shimmering side before writing
  597.  
  598.   3.7.  Write the CD-image to a CD
  599.  
  600.   Not much more left to do. Before showing you the last command, let me
  601.   warn you that CD-writers want to be fed with a constant stream of data
  602.   because they have only small data-buffers.  So the process of writing
  603.   the CD-image to the CD mustn't be interupted or a corrupt CD will be
  604.   the result.
  605.  
  606.   To be sure nothing can interupt this process, throw all users of the
  607.   system and unplug the ethernet-cable ...  Read the Bastard operator
  608.   from hell to learn about the right attitude to do so. ;-)
  609.  
  610.   If you are mentally prepared, dress up in a black robe, multiply the
  611.   SCSI-id of the CD-writer with it's SCSI-revision and light as many
  612.   candles, speak two verses of the ASR-FAQ and finally type
  613.  
  614.        cdwrite  --device /dev/sgd  cd_image
  615.        or
  616.        cdrecord -v speed=2 dev=4,0 cd_image
  617.  
  618.   depending on which software you want to use. Of course you have to
  619.   replace the example device with the scsi-device your writer is
  620.   connected to.
  621.  
  622.   Please note that no writer can re-position it's laser and can't
  623.   continue at the original spot on the CD when it gets disturbed.
  624.   Therefore any strong vibrations or even a shock will completly destroy
  625.   the CD you are writing.
  626.  
  627.   3.8.  If something goes wrong ...
  628.  
  629.   4.  Frequently asked questions with answers
  630.  
  631.   4.1.  How sensitive is the burning process?"
  632.  
  633.   Answer: that depends on your writer. Modern ones should have a data-
  634.   buffer of 1MB or such and can live 1-2 seconds without data.  See the
  635.   manuals or ask your manufacturer if you want to know the details.
  636.  
  637.   Regardless of the size of those data-buffers you must guarantee a
  638.   constant throughput of 300kb/s or 600kb/s in the long time run.
  639.  
  640.   Disk intensive processes such as updating the locate-database lower
  641.   the maximum flow-rate will surely corrupt the CD; you better check
  642.   such processes are not started via cron, at or anacron while you burn
  643.   CD-Rs.
  644.  
  645.   On the other hand, people reported that they compiled a kernel while
  646.   burning a CD without a glitch. Of course you need a fast machine for
  647.   such experiments.
  648.  
  649.   4.2.  Has fragmentation a bad impact on the throughput?"
  650.  
  651.   Fragmentation is usally so low that it's impact isn't noticed.
  652.  
  653.   If you're uncertain than look at the messages printed while booting,
  654.   the percentage of fragmentation is reported while checking the
  655.   filesystems. You can check for this value with the very dangerous
  656.   command
  657.  
  658.        bash> e2fsck -n  /dev/sda5        # '-n' is important!
  659.        [stuff deleted - ignore any errors]
  660.        /dev/sda5: 73/12288 files (12.3% non-contiguous)
  661.  
  662.   In this example the fragmentation seems to be very high - but there
  663.   are only 73 very small files on this filesystem (used as /tmp) so the
  664.   value is _not_ alarming.
  665.  
  666.   4.3.  Is it possible to store the CD-image on an UMSDOS-filesystem?"
  667.  
  668.   Yes. The only filesystem that isn't reliable and fast enough for
  669.   writing CDs from is the network filesystem (NFS).
  670.  
  671.   I'm using UMSDOS myself to share the disk-space between Linux and
  672.   DOS/Win on a PC (486/66) dedicated for writing CDs.
  673.  
  674.   4.4.  Isn't there some way to get around the iso9660 limitations?"
  675.  
  676.   Yes. You can put any filesystem you like on the CD. But other
  677.   operating systems than Linux won't be able to deal with this CD.
  678.  
  679.   Here goes the recipe:
  680.  
  681.   ╖  Create an empty file of 650MB size.
  682.  
  683.        dd if=/dev/zero of="empty_file" bs=1024k count=650
  684.  
  685.   ╖  Create an extended-2 filesystem on this file
  686.  
  687.        bash> /sbin/mke2fs  empty_file
  688.        empty_file is not a block special device.
  689.        Proceed anyway? (y,n) y
  690.  
  691.   ╖  Mount this empty file through the loopback-devices
  692.  
  693.        mount -t ext2 -o loop=/dev/loop1 empty_file /mnt
  694.  
  695.   ╖  Copy files to /mnt and umount it afterwards.
  696.  
  697.   ╖  Use cdwrite or cdrecord on empty_file (which is no longer empty) as
  698.      if it were an iso9660-image.
  699.  
  700.   If you want to make an entry in /etc/fstab for such a CD, disable the
  701.   checking of it, e.g.:
  702.  
  703.        /dev/cdrom  /cdrom  ext2  defaults,ro  0 0
  704.  
  705.   The first 0 means "don't include in dumps", the second (=important)
  706.   one means "don't check for errors on startup" (fsck will fail to check
  707.   the CD for errors).
  708.  
  709.   4.5.  How to read and write audio CDs?"
  710.  
  711.   Please get the packages "cdda2wav" and "sox", available from sunsite
  712.   and it's mirrors:
  713.  
  714.        <ftp://sunsite.unc.edu/pub/Linux/apps/sound/cdrom/cdda2wav0.71.src.tar.gz>
  715.  
  716.   <ftp://sunsite.unc.edu/pub/Linux/apps/sound/convert/sox-11gamma-
  717.   cb2.tar.gz>
  718.  
  719.   cdda2wav enables you to get a specific interval (or a whole track)
  720.   from your audio CD and converts it into a .wav-file.  sox converts the
  721.   wav-files back into the (audio-CD) cdda-format so it can be written to
  722.   the CD-R using cdwrite.
  723.  
  724.   4.6.  How to probe for SCSI-devices after boot?"
  725.  
  726.   The file drivers/scsi/scsi.c contains the information
  727.  
  728.        /*
  729.         * Usage: echo "scsi add-single-device 0 1 2 3" >/proc/scsi/scsi
  730.         * with  "0 1 2 3" replaced by your "Host Channel Id Lun".
  731.         * Consider this feature BETA.
  732.         *     CAUTION: This is not for hotplugging your peripherals. As
  733.         *     SCSI was not designed for this you could damage your
  734.         *     hardware !
  735.         * However perhaps it is legal to switch on an
  736.         * already connected device. It is perhaps not
  737.         * guaranteed this device doesn't corrupt an ongoing data transfer.
  738.         */
  739.  
  740.   4.7.  Is it possible to make a 1:1 copy of a data CD?"
  741.  
  742.   Yes. But you should be aware of the fact that any errors while reading
  743.   the original (due to dust or scratches) will result in a defective
  744.   copy.
  745.  
  746.   First case: you have a CD-writer and a seperate CD-ROM drive. By
  747.   issuing the command
  748.  
  749.        cdwrite -v -D /dev/sgc --pad -b  $(isosize  /dev/scd0) /dev/scd0
  750.        or
  751.        cdrecord -v dev=3,0 speed=2 -isosize /dev/scd0
  752.  
  753.   you read the data stream from the CD-ROM drive attached as /dev/scd0
  754.   and write it directly through /dev/sgc to the CD-R.
  755.  
  756.   Second case: you don't have a seperate CD-ROM drive. You have to use
  757.   the writer to read out the CD-ROM in this case:
  758.  
  759.        dd if=/dev/scd0 of=cdimage bs=1c count=`isosize  /dev/scd0`
  760.  
  761.   This command is equivalent to the result of mkisofs, so you should
  762.   procede as described in chapter 3. Please note that this method will
  763.   fails on audio CDs!
  764.  
  765.   4.8.  Can Linux read Joliet CDs?"
  766.  
  767.   Yes. But you need to patch the kernel and recompile it. For further
  768.   details see
  769.  
  770.        <http://www-
  771.        plateau.cs.berkeley.edu/people/chaffee/joliet.html>
  772.  
  773.   4.9.  How do I read/mount CD-ROMs with the CD-writer?"
  774.  
  775.   Just as you do with regular CD-ROM drives. No tricks at all. Note that
  776.   you have to use the scd-devices (SCSI CD-ROM) to mount CDs for
  777.   reading. Example-entry for /etc/fstab:
  778.  
  779.        /dev/scd0  /cdrom  iso9660  ro,user,noauto  0  0
  780.  
  781.   5.  Troubleshooting
  782.  
  783.   5.1.  It doesn't work: under Linux
  784.  
  785.   Please check first if the writer works under other operating systems.
  786.   Concretely:
  787.  
  788.   ╖  Does the controller recognize the writer as an scsi device?
  789.  
  790.   ╖  Does the driver software recognize the writer?
  791.  
  792.   ╖  Is it possible to make a CD using the accompanied software?
  793.  
  794.   If "it doesn't work" even under other operating systems you have a
  795.   hardware conflict or defective hardware.
  796.  
  797.   5.2.  It doesn't work: under DOS and friends
  798.  
  799.   Try to use Linux. Installation and configuration of SCSI-drivers for
  800.   DOS is the hell. Linux is too complicated? Ha!
  801.  
  802.   5.3.  Scsi errors during the burning phase
  803.  
  804.   Most likely those errors are caused by
  805.  
  806.   ╖  missing dis-/reconnect feature on the scsi bus
  807.  
  808.   ╖  unsufficiently cooled hardware
  809.  
  810.   ╖  defektive hardware (should be detected by 5.1.)
  811.  
  812.   Under various circumstances scsi devices dis- and reconnect themselves
  813.   (electronically) from the scsi bus. If this feature is not available
  814.   (check controller and kernel parameters) some writers run into trouble
  815.   during burning or fixating the CD-R.
  816.  
  817.   Especially the NCR 53c7,8xx SCSI driver has the feature disabled by
  818.   default, so you might want to check it first:
  819.  
  820.        NCR53c7,8xx SCSI support                  [N/y/m/?] y
  821.           always negotiate synchronous transfers [N/y/?] (NEW) n
  822.           allow FAST-SCSI [10MHz]                [N/y/?] (NEW) y
  823.           allow DISCONNECT                       [N/y/?] (NEW) y
  824.  
  825.   6.  Credits
  826.  
  827.      Andreas Erdmann <erdmann@zpr.uni-koeln.de>
  828.         provided the example with the YAMAHA-writer
  829.  
  830.      Art Stone <stone@math.ubc.ca>
  831.         had the idea to put non-iso9660 filesystems on a CD
  832.  
  833.      Bernhard Gubanka <beg@ipp-garching.mpg.de>
  834.         noticed the need of a recent version of mount to utilize the
  835.         loopback device
  836.  
  837.      Brian H. Toby
  838.         polished the wording.
  839.  
  840.      Bruce Perens <bruce@pixar.com>
  841.         gave information about the cdwrite-mailinglist
  842.  
  843.      Dale Scheetz <dwarf@polaris.net>
  844.         helped improving the section about creating the cdimage.
  845.  
  846.      Edwin H. Kribbs
  847.         reported that '-K' requires a patch for mkisofs
  848.  
  849.      Gerald C Snyder <gcsnyd@loop.com>
  850.         tested writing of an ext2 CD-ROM (see 4.4)
  851.  
  852.      Ingo Fischenisch <ingo@mi.uni-koeln.de>
  853.         provided the example with 2 controllers hosting 2 devices
  854.  
  855.      Janne Himanka <shem@oyt.oulu.fi>
  856.         pointer to kernel patch to read Joliet CDs
  857.      Joerg Schilling <schilling@fokus.gmd.de>
  858.         information about cdrecord
  859.  
  860.      Jos van Geffen <jos@tnj.phys.tue.nl>
  861.         noted the problem in 4.9.
  862.  
  863.      Markus Dickebohm <m.dickebohm@uni-koeln.de>
  864.  
  865.      Pierre Pfister <pp@uplift.fr>
  866.         helped to develop the recipe on 1:1 copies.
  867.  
  868.      Rick Cochran <rick@msc.cornell.edu>
  869.         hint about dis-/reconnect disabled by default in the ncr driver
  870.  
  871.      Stephan Noy <stnoy@mi.uni-koeln.de>
  872.         information and experience about writing audio-CDs
  873.  
  874.      Stephen Harris <sweh@mpn.com>
  875.         contributed hint about writing audio-CDs
  876.  
  877.      The Sheepy One <kero@escape.com>
  878.         suggested using defective CDs as coasters for drinks
  879.  
  880.      Volker Kuhlmann <kuhlmav@elec.canterbury.ac.nz>
  881.         noticed that the "cdwrite"-package does not contain mkisofs
  882.  
  883.   End of the Linux CD-Writing mini-HOWTO
  884.  
  885.