Previous Next Table of Contents

2. Prepare your Linux-system for writing CD-ROMs

Support for IDE CD-writers under Linux came suddenly in November 1997. Until then, this HOWTO had only to cover SCSI devices and still waits for a major re-write. The good news is, that dealing with IDE devices is much easier and you can still use this HOWTO if you just forget about the "generic SCSI devices" mentioned in several sections.

Before you report a (strange) error about the software for burning CD-Rs, please make sure you have compiled the binaries yourself. Under Linux, some versions of the C-library are incompatible (buggy), so that an application linked against one version will not work with another. An example for an error triggered by pre-compiled binaries is the following:

[root@Blue /dev]# cdrecord -eject dev=2,0
cdrecord: No such file or directory. No read access for 'dev=2,0'.

For the following, lets assume your binaries are all working properly. To find out how to address IDE devices you can issue the command cdrecord -scanbus.

2.1 A note on writing CD-Rs under Linux

In contrast to other rumours, the Linux-kernel does _not_ require a patch in order to write to CDs. Although the file drivers/scsi/scsi.c from the kernel-sources contains the lines

case TYPE_WORM:
case TYPE_ROM:
 SDpnt->writeable = 0;

this does only mean that that CDs and WORMs are not writeable through the standard-devices /dev/sda-/dev/sdh, which is ok. Instead of using these devices the writing of CDs is done through the so called generic SCSI-devices which permit nearly everything, even writing to CDs.

2.2 Set up the hardware

SCSI CD-writers

Shut down your computer, switch it off and hook CD writer to the SCSI-bus. Make sure the SCSI-bus is properly terminated and choose a free SCSI-ID for the writer. Look at the Linux SCSI-HOWTO if you're not sure. If you're completely clueless, ask an expert.

Switch the power on again and check the messages that the BIOS of the SCSI-controller prints immediately after switching the power on. If it doesn't recognize your writer, start over again.

Create the generic devices

The Linux SCSI-HOWTO says about generic SCSI-devices:

The Generic SCSI device driver provides an interface for sending SCSI commands to all SCSI devices - disks, tapes, CDROMs, media changer robots, etc.

Speaking of the generic devices as interfaces means that they provide an alternate way of accessing SCSI-hardware than through the standard devices. This alternate way is required because the standard devices are designed to read data block-wise from a disk, tape or cd-rom. Compared to this, driving a CD-writer or a scanner is more exotic, e.g commands to position the laser must be transmitted. To have a clean and therefore fast implementation of standard-devices, all such exotic actions must be done through the 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.

Goto the /dev-directory and check for generic SCSI devices; ls-command should show sga-sgh:

bash> cd /dev
bash> ls -l sg*
crw-------   1 root   sys     21,   0 Jan  1  1970 sga
crw-------   1 root   sys     21,   1 Jan  1  1970 sgb
crw-------   1 root   sys     21,   2 Jan  1  1970 sgc
crw-------   1 root   sys     21,   3 Jan  1  1970 sgd
crw-------   1 root   sys     21,   4 Jan  1  1970 sge
crw-------   1 root   sys     21,   5 Jan  1  1970 sgf
crw-------   1 root   sys     21,   6 Jan  1  1970 sgg
crw-------   1 root   sys     21,   7 Jan  1  1970 sgh

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

bash> cd /dev/
bash> ./MAKEDEV sg

Now the device-files should show up.

Enable usage of the generic SCSI devices

The Linux-kernel needs a module that lends it the ability to deal with generic SCSI devices. If your running kernel has this feature, it should be listed in the pseudo-file /proc/devices:

bash> cat /proc/devices | grep " s"
21 sg          <----- stands for "SCSI generic device"
 8 sd          <----- stands for "SCSI disk"
11 sr          <----- stands for "SCSI CD-ROM"

Maybe you have to issue the commands insmod sg or insmod sr_mod to load the modules into the kernel. Check again after you've tried this. If one of them doesn't succeed, you must re-configure your kernel and re-compile it:

bash> cd /usr/src/linux
bash> make config
[..]
*
* SCSI support
*
SCSI support (CONFIG_SCSI) [Y/m/n/?] Y
*
* SCSI support type (disk, tape, CD-ROM)
*
SCSI disk support (CONFIG_BLK_DEV_SD) [Y/m/n/?] Y
SCSI tape support (CONFIG_CHR_DEV_ST) [M/n/y/?] M
SCSI CD-ROM support (CONFIG_BLK_DEV_SR) [M/n/y/?] M
SCSI generic support (CONFIG_CHR_DEV_SG) [M/n/y/?] M

Please note that only the important questions are shown above.

2.3 Enable usage of loopback devices

The Linux-kernel needs a module that lends it the ability to deal with loopback devices. If your running kernel has this feature, it should be listed in the pseudo-file /proc/devices:

bash> cat /proc/devices | grep loop
 7 loop        <----- we even can use the loop-devices

Maybe you have to issue the command insmod loop to load the module into the kernel. Check again after you've tried this. If it doesn't succeed, you must re-configure your kernel and re-compile it as shown below:

bash> cd /usr/src/linux
bash> make config
[..]
*
* Additional Block Devices
*
Loopback device support (CONFIG_BLK_DEV_LOOP) [M/n/y/?] M
[..]
ISO9660 cdrom filesystem (CONFIG_ISO9660_FS) [Y/m/n/?] M

Please note that only the important questions are shown above.

2.4 Build and install the kernel

If you have questions regarding to this the Linux Kernel-HOWTO is the suggested reading. Furthermore your Linux-distribution should ship with some documentation about this issue. Hint: while re-compiling, you can continue with steps 2.7-2.9.

2.5 Reboot the computer for the changes to take effect.

Don't panic if the Linux-kernel prints the messages faster than you can read them. At least the initialization of SCSI-devices can be re-displayed with the command dmesg:

scsi0 : NCR53c{7,8}xx (rel 17)
scsi : 1 host.
scsi0 : target 0 accepting period 100ns offset 8 10.00MHz
scsi0 : setting target 0 to period 100ns offset 8 10.00MHz

  Vendor: FUJITSU   Model: M1606S-512        Rev: 6226
  Type:   Direct-Access                      ANSI SCSI
Detected scsi disk sda at scsi0, channel 0, id 0, lun 0

  Vendor: NEC       Model: CD-ROM DRIVE:84   Rev:  1.0a
  Type:   CD-ROM                             ANSI SCSI
Detected scsi CD-ROM sr0 at scsi0, channel 0, id 4, lun 0

scsi : detected 1 SCSI disk total.
SCSI device sda: hdwr sector= 512 bytes. Sectors= 2131992

Shown above is only that part of the initialization-messages that report the detection of physically present SCSI-devices.

2.6 Create loopback devices

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

bash> cd /dev
bash> ls -l loop*
brw-rw----   1 root  disk    7,   0 Sep 23 17:15 loop0
brw-rw----   1 root  disk    7,   1 Sep 23 17:15 loop1
brw-rw----   1 root  disk    7,   2 Sep 23 17:15 loop2
brw-rw----   1 root  disk    7,   3 Sep 23 17:15 loop3
brw-rw----   1 root  disk    7,   4 Sep 23 17:15 loop4
brw-rw----   1 root  disk    7,   5 Sep 23 17:15 loop5
brw-rw----   1 root  disk    7,   6 Sep 23 17:15 loop6
brw-rw----   1 root  disk    7,   7 Sep 23 17:15 loop7

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

bash> cd /dev/
bash> ./MAKEDEV loop

The last command only succeeds if you have the loop-module in your kernel (see 2.4 for handling of modules). If insmod loop does not help, you must wait until the new kernel is properly installed (see 2.5).

2.7 Get the user-software for burning CDs

Command line utilities

Creating CD-images

One of the following packages are required to generate prototypes of CD-Rs:

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

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

Depending on the model of your CD-writer (see 1.3), one of the following software for writing prototypes to CD-Rs is required:

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

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 use the mkisofs shipped with cdrecord has a few extensions (referenced in the documentation of cdrecord).

cdda2wav-0.95

cdda2wav reads audio data given by the cdrom drive and dumps it into a wav sound file. The sampling format can be controlled by options.

ftp://ftp.gwdg.de/pub/linux/misc/cdda2wav/

Graphical user interfaces (optional)

BurnIT (JAVA GUI):

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

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

X-CD-Roast

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


Previous Next Table of Contents