home *** CD-ROM | disk | FTP | other *** search
/ Freelog Special Edition 1: Linux / CD1.iso / doc / HOWTO / CD-Writing-HOWTO < prev    next >
Text File  |  1998-10-14  |  35KB  |  917 lines

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