This was written in 2004. Things have improved by then and I have not updated this at all.

Table of contents

Introduction
ide-scsi tunnel
The problems with CD writing
Basic usage of cdrecord for CD-XA (ISO image, etc.)
Writing CD-DA (Digital audio)
Writing Mixed-mode
Writing CD-Extra
DVD-R and -RW
DVD+R and DVD/DL+R
DVD+RW
DVD-RAM
Flash cards and Magtapes
Basic usage of cdda2wav
Basic usage of mkisofs
Further references, help and links

Introduction

Cdrecord (homepage) has been the cd writing tool for many years. Most frontends, both textual and graphical, or just simple wrappers use it every day. It is the only tool I know of that supports all media types: CD-R/RW, DVD-R/RW, DVD+R/RW, DVD-DL and even CF (flash cards)! Cdrecord also has more options than any other tool. Here's how to use the new things.

This article applies to Linux 2.6 ONLY. It is safe to use kernels above, including, 2.6.5.

ide-scsi tunnel

What kind of CD drive do you have? (Probably IDE/ATAPI) Now guess what protocol it uses: SCSI. ATAPI stands for ATA Packet Interface, which is an encapsulation of SCSI commands into ATA commands over the IDE wire.

Excerpt from cdrecord(1) manpage

Cdrecord is completely based on SCSI commands but this is no problem as all CD/DVD writers ever made use SCSI commands for the communication. Even ATAPI drives are just SCSI drives that inherently use the ATA packet interface as SCSI command transport layer build into the IDE (ATA) transport.

So, in the late Linux 2.4 series (starting with 2.4.20 IIRC) and anywhere within 2.6, you do not need the ide-scsi module anymore. Cdrecord can now use /dev/hdc as device, even though it claims it is an unsupported method. In fact, the ide-scsi in 2.6 is broken -- or rather not-updated-to-2.6, but which is the same.

Or in short: No need for ide-scsi in 2.6.

The problems with CD writing

SUSE 9.1 and up for example ship a "bastardized" version of Cdrecord called cdrecord-dvd (cdrdvd for short in this document), whose only extra feature seems to be DVD-Minus support, but I did not try that yet. And I probably will not, because the clone proves inferior right at the start: Here, look at the output of querying the TOC of a DVD+RW with the two different tools:

# cdrecord-dvd -dev=/dev/hdc -toc -v
cdrecord-dvd: Found DVD media: using cdr_mdvd.
...
TOC Type: 1 = CD-ROM
Using libscg version 'schily-0.8'.
atapi: 1
Device type    : Removable CD-ROM
Version        : 0
Response Format: 2
Capabilities   :
Vendor_info    : 'HL-DT-ST'
Identifikation : 'DVDRAM GSA-4160B'
Revision       : 'A301'
Device seems to be: Generic mmc2 DVD-R/DVD-RW.
Current: 0x001A
Profile: 0x0012
Profile: 0x0011
Profile: 0x0014
Profile: 0x0013
Profile: 0x001A (current)
Profile: 0x001B
Profile: 0x002B
Profile: 0x0010
Profile: 0x0009
Profile: 0x000A
Profile: 0x0008
Profile: 0x0002
Using generic SCSI-3/mmc DVD-R(W) driver (mmc_mdvd).
Driver flags   : SWABAUDIO BURNFREE
Supported modes: PACKET SAO
Drive buf size : 851968 = 832 KB
Drive DMA Speed: 13006 kB/s 73x CD 9x DVD
Current Secsize: 2048
  ATIP start of lead in:  -150 (00:00/00)
Disk type:    unknown dye (reserved id code)
Manuf. index: -1
Manufacturer: unknown (not in table)
first: 1 last 1
track:   1 lba:         0 (        0) 00:02:00 adr: 1 control: 4 mode: -1
track:lout lba:   2295104 (  9180416) -1:59:74 adr: 1 control: 4 mode: -1

# cdrecord -dev=/dev/hdc -toc -v
Cdrecord-ProDVD-ProBD-Clone 2.01.01a37 (i686-pc-linux-gnu) Copyright (C) 1995-2008 Jörg Schilling
...
TOC Type: 1 = CD-ROM
Using libscg version 'schily-0.8'.
atapi: 1
Device type    : Removable CD-ROM
Version        : 0
Response Format: 2
Capabilities   :
Vendor_info    : 'HL-DT-ST'
Identifikation : 'DVDRAM GSA-4160B'
Revision       : 'A301'
Device seems to be: Generic mmc2 DVD-R/DVD-RW.
Current: DVD+RW
Profile: DVD-RAM
Profile: DVD-R sequential recording
Profile: DVD-RW sequential overwrite
Profile: DVD-RW restricted overwrite
Profile: DVD+RW (current)

Profile: DVD+R
Profile: Unknown (DVD+R DL)
Profile: DVD-ROM
Profile: CD-R
Profile: CD-RW
Profile: CD-ROM
Profile: Removable Disk
Using generic SCSI-3/mmc-3 DVD+RW driver (mmc_dvdplusrw).
Driver flags   : DVD MMC-3 SWABAUDIO BURNFREE
Supported modes: PACKET SAO
Drive buf size : 851968 = 832 KB
Current Secsize: 2048
book type:       DVD+RW, Version 2 (9.2)
disc size:       120mm (0)
minimum rate:    Not specified (15)
number of layers:0
track path:      Parallel Track Path (0)
layer type:      illegal layer type (4)
linear density:  0.267 µm/bit (0)
track density:   0.74 µm/track (0)
phys start:      196608
phys end:        1810959
end layer 0:     0
bca:             0
phys size:...    1614352
Manufacturer:    'PHILIPS'
Media type:      '041'
copyr prot type: 0
region mgt info: 0
cpm:             0
cgms:            0
first: 1 last 1
track:   1 lba:         0 (        0) 00:02:00 adr: 1 control: 4 mode: -1
track:lout lba:   2295104 (  9180416) -1:59:74 adr: 1 control: 4 mode: -1

Note the differences in the "Profile" list -- cdrdvd(suse) prints bare hex numbers while Cdrecord(original) gives me the proper modes. But there it is clearly: cdrdvd uses "generic SCSI-3/mmc DVD-R(W) driver (mmc_mdvd)", while Cdrecord luxurizes us with something more appropriate for the disc (a DVD+RW) I put in: "Using generic SCSI-3/mmc-3 DVD+RW driver (mmc_dvdplusrw)". And a personal note on the side: It is not that interesting, but Cdrecord hands out nice details about the disc properties.

Basic usage of Cdrecord for CD-XA (ISO image, etc.)

The standard way for writing a disc is:

# cdrecord -dev=/dev/hdc -dao -v mydisc.iso

This command works for any media, CD-R/RW, DVD-+R/RW, etc. See below for different methods for some media types.

-dev should be pretty self-explanatory, -dao enables the so-called "Disk At Once" method. The other remaining method is TAO "Track at once", where the cd writer stops after each track. (Only relevant for CD-DA, Multi-mode or CD-Extra.) -v enables the display of a progress counter which shows how much MB have been written so far, buffer status, write speed. There is also SAO, "Session At Once", which is mostly used behind DAO because you usually write only one session, and writing two fixated-style sessions in DAO does not seem to be supported by drives.

Whereas with ide-scsi you used like -dev=0,0,0, it is easier with the new -dev=/dev/hdc approach. There are two other methods, -dev=ATAPI:1,0,0 and -dev=ATA:1,0,0, but which are unsupported from the kernel developers. They seem to work, though. -dev=/dev/hdc is correct way (according to LKML), even though Cdrecord says it is not. (In fact, Cdrecord barks for any of the three ATAPI methods.)

There are many more options you can use. The most important you will ever need are -speed= and fs=. fs=32M for example sets the RAM cache size -- useful for when the disk is occassionally under load. If the disk is under permament load, let's hope that Cdrecord's Real-Time Mode (only activated when run as root) gains priority over the block schedulers. If you use slow storage, such as floppy (a bad example), bad harddisk (a bad hd does not need to click, the transfer rate just drops) or slow network link, fs= cannot really help you. You could use fs=700M to buffer the whole input, but that needs a hell of RAM -- and if you did that, you are advised to use a ramdisk instead, because you cannot map more than 3 GB into your address space on 32-bit processors, which impacts when you write a full 4-or-more GB DVD.

Writing CD-DA (Digital Audio)

You just need the additional flag -audio to denote CD-DA mode and a bunch of WAV files to write. If you are worried about whether discs can be read in standalone CD players, I can tell you something: I have written discs with speed 40, and they were readable. On the other hand, I have also written discs at speed 4, and they were not readable. (And that with the same ol' cd player! Yet, I used "standard" computer discs for data rather than special CD-DA discs.)

# cdrecord -dev=/dev/hdc -v -dao -audio trk01.wav trk02.wav

Writing Mixed-Mode

Mixed mode is where track 1 contains data, and all others contain digital audio. Syntax is:

# cdrecord -dev=/dev/hdc -v -dao mydisc.iso -audio trk01.wav trk02.wav

Writing CD-Extra

CD-Extra is a special method of Mixed Mode, where the data track is not in the first session. Older CD players do not distinguish between an audio and a data track and blindly play anything they get. Playing data tracks can damage your speakers -- and if not that, your own ears. The trick is that such old CD players mostly do not recognize more than one session, so it seems best to stuff the data track somewhere where it cannot be read, like the second session.

Session 1; Tracks 1-12: Audio
Session 2; Track 13: Data
(Example)

I am not completely aware of the syntax, but you could try the following:

# cdrecord -dev=/dev/hdc -v -multi -sao -audio trk01.wav trk02.wav
# cdrecord -dev=/dev/hdc -v -tao -data mydisc.iso

The second commands must use TAO, as choosing SAO mode failed for my test run. I do not exactly know why.

DVD-R and -RW

The DVD-Minus can be seen as just a size extension to the CD. The methods for writing remain the same.

DVD+R and DVD/DL+R

Gah, it's really mixed here. It uses some kind of PACKET mode for DVD-Plus, but is still one-write only. Strange, eh? Nevertheless, do not care what's behind, what you get is the same. Interesting things start with DVD+RW.

Use the above-mentioned standard command.

cdrecord currently does not recognize DoubleLayer media, but it can write it without problems. Just pass the -driver=mmc_dvdplusr option to it.

DVD+RW

First is, that you can of course use the "standard way" described above for CD-R, it works with about anything.

The second way is to use the DVD+RW like a hard drive. This requires a recent 2.6 kernel. The DVD will need to be formatted in a mode similar to PACKET mode before it can be used. (In case of the "standard way", it is automatically formatted by Cdrecord beforehand.)

# cdrecord -dev=/dev/hdc -v -format

After it has been formatted, it can be used like a normal read-write block device. This means:

that you can put any filesystem on it, mount it, and whatnot. Putting a fs designed for harddisks on a optical disc is crazy, but it works. Thanks to the buffer cache and such, the atime updating is not noticable. However, if you intend to use it as such, you should use the UDF filesystem specially designed for this:

# mkudffs /dev/hdc
# mount /dev/hdc

And there you go. (So what the standard way does, is nothing but cat mydisc.iso >/dev/hdc.) The JFFS ("Journalling Flash File System") could also be a solution, because it takes advantage of knowing about the physics of Flash media. This includes writing to all sectors equally, since writing to memory bits uses voltage force -- you can read more about it on Wikipedia. (Links at the end of the article.) The same also applies to RW media -- rewriting the same spot over and over means changing the phase from amorphous to crystalline forth and back (depending on whether you write a zero or a one). It is easy to make a byte-bit amorphous (unordered atom/molecule structure), but the operation is not 100% reversible.

DVD-RAM

I have not experimented with this kind of media yet. Please see Wikipedia for a good description. Based on that

Flash Cards and Magtapes

Surprisingly, cdrecord -scanbus returns this for my machine:

scsibus0:
  0,0,0     0) 'IC      ' 'USB Storage-CFC ' '301b' Removable Disk
  0,1,0     1) *
  0,2,0     2) *
  0,3,0     3) *
  0,4,0     4) *
  0,5,0     5) *
  0,6,0     6) *
  0,7,0     7) *

which means it can write to Compact Flash Cards also. I tested it even less than DVD-RAM (read: less than never), but I guess it works the same as DVD+RW.

It might happen that magnetical tape drives or other SCSI and/or SCSI-emulated media might appear here, too. Do not hesitate to expiremt.

Basic usage of cdda2wav

A good tool to copy CD-DA discs to WAV files. In contrast is cdparanoia which is said to have better error correction, but I am too lame to install it, for cdparanoia has less functionality. (Cdparanoia is NOT developed by Jörg Schilling, but Cdda2wav is.) The basic syntax is:

$ cdda2wav -D /dev/hdc -B -t 1+20

-B specifies that the extracted data should not go into one file, -t specifies the track selection, here from track 1 to (including) 20.

Basic usage of mkisofs

Just as with all the tools presented here, mkisofs also has so many options you will rarely need (read: nothing fancy such as bootable CDs, etc.)

For each directory listed on the mkisofs line, mkisofs descends into it and takes its contents into the root folder. Files listed on the arglist are also taken right into the root directory, so the following directory structure will map as:

$ find .
./folder
./folder/foldfile
./folder/anotherfolder
./folder/anotherfolder/bla
./stdfile
$ find /mounted_iso
foldfile
anotherfolder
anotherfolder/bla
stdfile

And the basic command for it is:

$ mkisofs -J -R -v -v -v -o foobar.iso myfolder ormyfiles

You can add -V name to give the ISO-9660 image a label (which will show in Windows Explorer).

Further references, help and links

Your biggest friend are the manpages of cdrecord, cdda2wav and mkisofs.

Jörg Schilling's Cdrecord

Wikipedia: JFFS, Journalling Flash File System
Wikipedia: [CD-R], [CD-RW], [DVD-R], [DVD-RW], [DVD+R], [DVD+RW], [DVD-RAM], [Audio CD], [CD-XA], [CD-Extra]

Wikipedia: [Amorphous] [Crystal structure]