Dec 142000

cdrecord – writing your own CDs

While I was at BSDCon 2000, I was able to make a number of purchases.  These were wholly/partly funded by donations and from ad revenue.   One of the items was a Plextor CD-RW internal SCSI drive.  I chose SCSI because of advice I was given regarding SCSI reliability with respect to CDRW drives.  I chose Plextor because of the recommendations of others.  Plextor has also donated several drives to the cdrecord author (see here for details), including the drive model I bought.  That’s a good marketing move by Plextor.  It ensures the author can test and work with their hardware, thereby ensuring the software works well with that drive.

NOTE: In this article, I specify the speed which should be used to write to the CD.  You should adjust that value to suit your CD drive.

The sharp eyed amongst you may notice that the device used in this article differs from that used in the cdrecord – writing multiple sessions article.  That’s not magic.  And it’s not a mistake.  When I wrote this article, I had two SCSI cards in the box.  I’ve since returned one to it’s owner and put the CDRW on the same card as the two SCSI drives.

If you are using an IDE CD-RW, you may find Burning CDs on an IDE CD-RW helpful.

cdrecord resources

The home page for cdrecord is

The FAQ and How-To are at:


I have the entire ports tree.  So it was easy. cdrecord is now part of sysutils/cdrtools. When I first wrote this article, it was in sysutils/cdrecord. To install:

cd /usr/ports/sysutils/cdrtools
make install

You will also need mkisofs (as in Make ISO File System) for creating an ISO image. It is also in sysutils/cdrtools. In previous times, it was found in sysutils/mkisofs.

Kernel suggestions

The notes for FreeBSD users (see above link) suggest that you include the following options in your kernel:
options P1003_1B #Posix P1003_1B real-time extensions
# The above two POSIX options were already in my kernel.
# I added the following for cdrecord.
options _KPOSIX_VERSION=199309L

See Building and Installing a Custom Kernel in the FreeBSD Handbook for more information on modifying your kernel.

Know your CD drive

In order to use cdrecord, you need to know where your CD drive is installed.   Here’s an extract from dmesg on my box:
cd0 at ahc0 bus 0 target 5 lun 0
cd0: <PLEXTOR CD-R PX-W124TS 1.05> Removable CD-ROM SCSI-2 device 
cd0: 10.000MB/s transfers (10.000MHz, offset 8)
cd0: cd present [332860 x 2048 byte records]

cdrecord needs the bus, target, and lun values (in the above case, that’s 0,5,0).

But beware, cdrecord did not recognize the above.  Witness the following failure (I’ll explain what I was doing in the next section):

# cdrecord -dummy -eject blank=all dev=0,5,0
Cdrecord 1.9 (i386-unknown-freebsd4.2) 
                             Copyright (C) 1995-2000 J			

  5 Responses to “cdrecord – writing your own CDs”

  1. /usr/ports/sysutils/xcdroast is an X interface to cdrecord. I’ve not used it.

  2. If I copy a cdrom with
    dd if=/dev/cd0a of=/home/disc.iso bs=64k
    2k is works
    the system does almoust freeze.
    (1 GHz Duron UDMA-2 CD UDMA-4 HD)


  3. I found out today that the mkisofs step is only necessary if you want to mount the CD contents as a file system.

    Here’s what I accidentally did today:

    cdrecord -eject speed=12 dev=0,5,0 ~dan/fp2003.06_fbsd_fppho_fs_pho_phpads_.tgz

    Note that I supplied a compressed tarball to cdrecord, not an ISO as I usually do.

    I mentioned this (in a Linux channel on IRC), and was promptly told:

    that’s ok, you can access it with tar …

    So I can! Witness:

    # tar tzf /dev/cd0a

    Woo hoo! I’ll just keep that CD and mark it accordingly.

    • More info: I got these types of errors:

      # tar tzf /dev/cd0a
      tar (child): /dev/cd0a: Cannot read: Input/output error
      tar (child): At beginning of tape, quitting now
      tar (child): Error is not recoverable: exiting now

      So I tried:

      $ sudo cat /dev/acd0a > raw.tgz
      cat: /dev/acd0a: Input/output error

      [after a long delay]

      Next was:

      $ sudo cat /dev/acd0c | tar tvzf –

      [lots of output]

      -rw-r–r– ftpbackup/ftpbackup 34249 Jul 29 03:17 2003 freshsource_phorum.2003.07.29.sql
      cat: /dev/acd0c: Input/output error
      -rw-r–r– ftpbackup/ftpbackup 34249 Jul 30 03:17 2003 freshsource_phorum.2003.07.30.sql
      -rw-r–r– ftpbackup/ftpbackup 34249 Jul 31 03:17 2003 freshsource_phorum.2003.07.31.sql
      -rw-r–r– ftpbackup/ftpbackup 34249 Aug 1 03:17 2003 freshsource_phorum.2003.08.01.sql

      gzip: stdin: unexpected end of file
      tar: Unexpected EOF in archive
      tar: Error is not recoverable: exiting now

      Next tried was:

      $ sudo cat /dev/acd0c > raw.tgz
      cat: /dev/acd0c: Input/output error

      At this point, I suspected the original tarball, but that was fine:

      $ tar tvzf ~dan/fp2003.06_fbsd_fppho_fs_pho_phpads_.tgz

      [no errors]

      And then:

      $ sudo dd if=/dev/acd0c bs=2k of=raw.tgz
      dd: /dev/acd0c: Input/output error
      288985+0 records in
      288985+0 records out
      591841280 bytes transferred in 965.288864 secs (613123 bytes/sec)

      While all the above was going on, I was creating an ISO and burning new CDs…

      My advice: ignore what I said. This whole thread is now merely a curiousity.

      • Oh, that tarball I got from the dd? I did this:

        $ tar xvfz raw.tgz

        I got:

        … [snipped]

        gzip: stdin: decompression OK, trailing garbage ignored
        tar: Child returned status 2
        tar: Error exit delayed from previous errors

        So that looks ok, just a bit of extra data is rounding up to the block size: 591841280 is 591839307 rounded up to 2k