Next Previous Contents

2. Setup the Linux-system for writing CD-ROMs

This section applies to all types of CD-writers, including devices for SCSI, IDE/ATAPI and the parallel port. The later two types of devices require compatibility drivers, which make them appear as if they were real SCSI devices. On the one side such a unifying strategy is easy ("everything is SCSI"), because on the application level you can share your knowledge with other users regardless of their kind of CD-writer. On the other side, you have to reconfigure applications like audio CD players or the mount utility to reflect the change of the driver name. For example, if you accessed your ATAPI CD-writer through the device file /dev/hdc before, you will have to access it through /dev/scd0 after activating the SCSI compatibility drivers.

Once you succeed setting up your hardware and the rest of your Linux-system, the command cdrecord -scanbus shows you a list of devices on your SCSI busses. The goal of this section is to guide you in setting up your Linux-system, so that you finally end up seeing something like:

shell> cdrecord -scanbus
Cdrecord release 1.7a1 Copyright (C) 1995-1998 Jörg Schilling
scsibus0:
          0) 'Quantum ' 'XP34300         ' 'F76D' Disk
          1) 'SEAGATE ' 'ST11200N        ' '8334' Disk
          2) *
          3) 'TOSHIBA ' 'MK537FB/        ' '6258' Disk
          4) 'WANGTEK ' '5150ES SCSI 36  ' 'ESB6' Removable Tape
          5) 'EXABYTE ' 'EXB-8500-85QUE  ' '0428' Removable Tape
          6) 'TOSHIBA ' 'XM-3401TASUNSLCD' '3593' Removable CD-ROM
          7) *
scsibus1:
        100) 'Quantum ' 'XP31070W        ' 'L912' Disk
        101) *
        102) *
        103) 'TEAC    ' 'CD-R55S         ' '1.0H' Removable CD-ROM
        104) 'MATSHITA' 'CD-R   CW-7502  ' '4.02' Removable CD-ROM
        105) *
        106) 'YAMAHA  ' 'CDR400t         ' '1.0d' Removable CD-ROM
        107) *
Listing: Detecting devices on your SCSI bus

The example was provided by Jörg Schilling and shows a total of four CD-writers. Please note that -scanbus also reports other devices, e.g. regular CD-ROMs and hard disk drives. The last column gives the SCSI description of the device, from which you cannot clearly distinguish ordinary CD-ROM drives from those with burning capability. But the product identification (middle column) often has hints about the feature in form of a R, -R or -RW.

2.1 Set up the Linux kernel

The Linux kernel can be equipped with drivers for various features. You can compile the drivers into the kernel image statically or you can compile them as a module for on-demand loading. The last method is preferred for drivers not essential for bringing your Linux-system into life, because your kernel will be smaller and faster then. However, some drivers are essential for the system to come up and you shouldn't compile them as a module. Example: if your system lives on an IDE hard disk, you must have the driver for IDE hard disks in the kernel -- not as a module.

There are three different types of CD-writers: SCSI, IDE/ATAPI and external writers that work through the parallel port. The table shows how to configure the Linux kernel for those hardware types. The first column of the table is the section of the kernel configuration menu, where you can find the setting. The second column is the description of the feature (taken from the kernel configuration menu, too). The third column gives the name of the resulting module. The columns named SCSI, IDE and PP contain the necessary options for the associated hardware (PP = parallel port).

Sect.  Description                 Module   SCSI  IDE   PP
------------------------------------------------------------
BLOCK  Enhanced IDE/MFM/RLL...                     Y      
BLOCK  IDE/ATAPI CDROM             ide-cd          M     
BLOCK  SCSI hostadaptor emulation  ide-scsi        M      
BLOCK  Loopback device             loop       M    M     M

PARIDE Parallel port IDE device    paride               Y/M
PARIDE Parallel port ATAPI CD-ROMs                       M
PARIDE Parallel port generic ATAPI                       M
PARIDE (select a low-level driver)                       Y

SCSI   SCSI support                scsi_mod  Y/M  Y/M    
SCSI   SCSI CD-ROM support         sr_mod    Y/M  Y/M     
SCSI     Enable vendor-specific               Y    Y      
SCSI   SCSI generic support        sg        Y/M  Y/M     
SCSI   (select a low-level driver)            Y

FS     ISO 9660 CDROM filesystem   iso9660    Y    Y     Y
FS     Microsoft Joliet cdrom...   joliet    M/Y  M/Y   M/Y
Table: driver selection for different writer types

Y stands for yes and means you should put the beast into the kernel. M stands for module and means you should or must compile this feature as a module. Y/M gives you the option to decide between either (order indicates choices with less potential problems). Empty settings don't need to be modified and not changing them increases the chance that the resulting kernel will work for you (if it did before...). Especially in environments where SCSI and ATAPI devices are mixed, you better build most things as modules.

Compiling loopback device is optional. It allows you to test the image before writing it to the media. If you want to be able to read CD-ROMs, you need support for the ISO 9660 filesystem. This driver automatically includes RockRidge Extensions. The Microsoft Joliet CD-ROM extensions have to be explicitely added to the ISO 9660 filesystem. In any case, you need a low-level driver for your hardware. Low-level refers to the driver, which interacts directly with the hardware. For SCSI and the parallel port, there are a lot of low-level drivers available.

To have the modules loaded, you should either list them in a configuration file like /etc/modules or run the daemons kerneld or kmod, which both load the required modules automatically for you when the kernel sees a needs for them. To make your life with modules easier, you can add the following lines to /etc/conf.modules:

alias   scd0 sr_mod                  # load sr_mod upon access of scd0
alias   scsi_hostadaptor ide-scsi    # SCSI host adaptor emulation
options ide-cd ignore=hdb            # if /dev/hdb is your CD-writer
Some settings for using IDE/ATAPI writers

The aliases provide alternate names for the same module and are not essential. The options provide a way to make options for module loading permanent, i.e. after you have sucessfully used them with modprobe/insmod. To learn about different options for different modules, read on.

Description                     command
-------------------------------------------------
Show active drivers             cat /proc/devices
List active modules             cat /proc/modules
List available modules          modprobe -l
Remove a module                 modprobe -r
Load a module manually          modprobe
Load a module upon startup      echo "list it in /etc/modules"
                                (please consult the docs of your distr.)
Load modules on demand          echo "have kmod or kerneld running"
Table: commands to deal with kernel modules and drivers

If you need a module not available on your system, you must recompile and reinstall the kernel. Please read the Kernel HOWTO for more information on this. The most recent information about handling of kernel modules can be read in the Module HOWTO. If you succeed in building or finding the required modules, either add their names to /etc/modules or let an automatic facility (kmod, kerneld) load them for you. Consult the documentation of your Linux-distribution if you are unsure.

If you are on your own, then try to install a package called "Linux Kernel source", which was shipped with your distribution. Afterwards issue the following commands:

cd /usr/src/linux
make menuconfig  # follow instructions and menu
make dep
make zImage      # or "make bzImage"
# insert a floppy-disk before proceding
dd if=arch/i386/boot/zImage of=/dev/fd0
make modules
make modules_install
Table: making a bootable floppy disk

This will produce a bootable floppy disk. If you are really clueless about this whole stuff, you better read other documentation like the Kernel HOWTO or get help from a friend before you completely mess up your system. Remember the kernel is the heart of the system.

Special hints up to kernel version 2.2.9

Owners of ATAPI CD-writers beware: if your kernel detects your writer as an ATAPI device during system startup, you have no chance of getting it to work as a CD-writer under Linux. Once the IDE/ATAPI driver grabs the device, the SCSI driver (on the top of the host adaptor emulation) can no longer do so. Please recompile a kernel with the CD-ROM stuff as a module like it is shown in the table above.

With 2.2 and above, you can control the greediness of the ide-cd driver with the parameter "ignore=". If you enable this, the driver won't grab the specified device, so it will be available when the SCSI host adaptor emulation is activated. Example: use "modprobe ide-cd ignore=hdb", if your ATAPI writer is hdb and you want the ide-scsi driver to treat hdb as a scsi device [usually sr0]. There is no way to specify this on the kernel commandline (like in 2.0).

Up to kernel version 2.2.9, don't enable CONFIG_SCSI_MULTI_LUN ('probe for multiple luns') and ide-scsi support at the same time, there is an ide-scsi bug that prevents this.

Some users reported conflicts with pre-compiled binaries and the 2.2-release. This is a problem with the Linux kernel. Possible solutions:

Special hints with kernel version 2.2.10 and later

It was reported to me that kernels from 2.2.10 onwards provide you with both the option from the 2.0.x-series and the option from the earlier 2.2.x-series. The author recommends the strategy of telling the kernel which device should be managed by which driver, like it is done in 2.0.37. The following describes that method:

Special hints for the 2.0.x-series

Kernels prior to 2.0.31 have several bugs and can't read the last file on a CD-ROM. Please upgrade to 2.0.37 or higher. For this version, the feature which used to be named "SCSI emulation" has been more accurately renamed "SCSI host adaptor emulation.

With kernels 2.0.37 and above, you can select which driver (IDE or SCSI) to use for which ATAPI device. To be more precise, you can add the feature "SCSI hostadaptor emulation" to your kernel and activate the emulation for specific devices on the kernel command line (while booting). For example, if your CD-writer has the device file name /dev/hdb, then add the statement hdb=ide-scsi. The following listings show how to make this setting permanent through the bootmanagers LILO and chos.

image=/boot/zImage-2.0.37
  label=Linux
  read-only
  append="hdb=ide-scsi"
Listing: Example configuration for lilo (/etc/lilo.conf)

linux "Linux 2.0.37" {
        image=/boot/zImage-2.0.37
        cmdline= root=/dev/hda5 readonly hdb=ide-scsi
}
Listing: Example configuration for chos (/etc/chos.conf)

2.2 Hardware and device files

After you have installed all necessary drivers, boot the new kernel. It should have all the features you need for the following sections.

[Users of devfs need not bother with the following steps of manually setting up device files. If you use devfs, everything will automagically appear in the right place.]

Go to the /dev directory and check for loopback devices. It's not critical if you don't have these devices, but it's convenient if you do (see 3.5). If you already have them, the ls command should show loop0-loop7:

shell> cd /dev
shell> ls loop*
loop0 loop1 loop2 loop3 loop4 loop5 loop6 loop7
Listing: device files for loopback

If you don't have those device files, then create them by using the /dev/MAKEDEV script:

shell> cd /dev/
shell> modprobe loop   # load the module called "loop"
shell> ./MAKEDEV loop
Listing: commands to create loopback devices

The last command only succeeds if you have the loop module in your kernel. What you read so far about handling of loop device files can be applied to all other device files (sg*, pg*, hd*, ...) and is not explicitely mentioned again in this document.

In case your Linux distribution does not contain the script /dev/MAKEDEV, then create the devices manually with this loop:

for i in 0 1 2 3 4 5 6 7
do
        mknod /dev/loop$i c 7 $i
done

IDE/ATAPI CD-writers

ATAPI is an extension for IDE devices which is found in all newer IDE devices. The extension allows the SCSI protocol to be used on the IDE bus. Together with the kernel module ide-scsi, which turns your IDE-controller partly into a SCSI-controller, you can treat your IDE/ATAPI devices as if they were SCSI. So just load this module and proceed as if you had a SCSI writer.

SCSI CD-writers

Please make sure that your writer is recognized by the BIOS of your computer. It makes no sense to proceed if your computer does not accept the hardware (the fact that it doesn't spit it out should not be interpreted as a sign of confirmation; a message on the screen is required).

If you plan to connect your SCSI through the parallel port (not to confuse with the IDE drives for the parallel port), you need a special active cable and a special kernel driver. Read http://www.torque.net/parport/parscsi.html to learn more about this option.

Generic SCSI devices

The device files /dev/sd* and /dev/sr* for accessing SCSI hard disks and SCSI CD-ROM drives are limited to block-oriented data transfer. This makes them so fast and well suited for data storage. Driving the laser of a CD-writer is a more complicated task and requires more than block-oriented data transfer. To keep the sd* and sr* devices clean and fast, a seperate type of SCSI device was introduced, the so called generic SCSI devices. As everthing can be done to SCSI hardware through the generic devices, they are not fixed to a certain purpose -- therefore the name generic.

As true for other devices, you should find them in the /dev directory (by convention):

shell> cd /dev
shell> ls sg*
sg0  sg1  sg2  sg3  sg4  sg5  sg6  sg7

If you don't have those device files then create them by using the /dev/MAKEDEV script:

shell> cd /dev/
shell> ./MAKEDEV sg

If your Linux distribution does not have the script /dev/MAKEDEV, then create the devices manually with this loop:

for i in 0 1 2 3 4 5 6 7
do
        mknod /dev/sg$i c 21 $i
done

CD-writers for the parallel port

I have no clue about this, sorry. Please read http://www.torque.net/parport/paride.html or your local file /usr/src/linux/Documentation/paride.txt.

2.3 Get the user software for burning CD-Rs

A more detailed survey of tools related to produce CD-ROMs is available from http://www.fokus.gmd.de/research/cc/glone/employees/joerg.schilling/private/cdb.html.

Command line utilities

One of the following packages are required to generate images of CD-Rs (only required for data CD-ROMs):

ftp://tsx-11.mit.edu/pub/linux/packages/mkisofs/ (mkisofs)

ftp://ftp.ge.ucl.ac.uk/pub/mkhfs (mkhybrid)

To write images to the CD-R, you need one of the following software packages:

ftp://ftp.fokus.gmd.de/pub/unix/cdrecord/ (cdrecord)

http://www.ping.de/sites/daneb/cdrdao.html (cdrdao)

Don't trust the man page of (old) mkisofs which states you need version 1.5 of cdwrite. Just use cdrecord and you are fine. Please note that newer versions of cdrecord ship with an enhanced version of mkisofs and some extra tools in the subdirectory misc/ (readcd, isosize) not found elsewhere.

Graphical user interfaces (optional)

Front-ends are really front-ends under Linux. That means, you still have to install the command-line utilities, but you access them in a better looking manner.

X-CD-Roast is a program package dedicated to easy CD creation under Linux. It combines command line tools like cdrecord and mkisofs into a nice graphical user interface.

http://www.fh-muenchen.de/home/ze/rz/services/projects/xcdroast/e_overview.html

BurnIT is a JAVA front-end to cdrecord, mksiofs and cdda2wav-0.95 making it a complete package for burning CDs on the Unix platform. It is available from

http://sunsite.auc.dk/BurnIT/

XDaodio

This is a graphical frontend for cdrdao. Its main purpose is to make 1:1-copies of audio CDs.

http://www.lrz-muenchen.de/~MarkusTschan/


Next Previous Contents