How to Write a CD.

(Using free software on a Unix workstation).

This is intended for system administrators who want to back up files to a writeable CD.   Jörg Schilling's CDrecord software is used. These notes refer mainly to Solaris on Sun computers, however there is a list of supported operating systems at the CDrecord release information site.

Australian National University NMR Centre home page

CD-Recordable FAQ   |  Sun CD-ROM FAQ

To write a CD you need to:

  1. connect a SCSI CD writer to your computer. If your operating system is SunOS / Solaris, you will need to install scg - the SCSI General Driver. This is used by the kernel to control the CD writer.
  2. use the mkisofs program to create a disk image of the data to be backed up,
  3. use the cdrecord program to write the disk image to a CD.
  4. optionally use the sformat program to verify the data on the CD.
Software Versions:
These notes were written with reference to CDrecord-1.6.1 and mkisofs-1.11. CDrecord-1.6.1 includes Eric Youngdale's mkisofs-1.12b4, with modifications by Jörg Schilling. The b in 1.12b4 stands for beta, so this version may not be stable. Check out the mkisofs home page for information on the latest stable version.

The latest version of CDrecord is 1.8.1. I haven't tried this version yet but the installation procedure looks the same as version 1.6.1.
The software for both creating the disk image and driving a CD writer connected to a Unix host is available at If you're running SunOS or Solaris you will also need the scg driver (see the scg section below).

Cdrecord used to be available as either source or binary, but last time I looked there were no binary distributions at the site. However a binary distribution of cdrecord.1.8a24 and mkisofs 1.12b5 is available at the Solaris Package Archive. This site (and its mirrors) contains packages that can be easily installed with the Solaris pkgadd command. See the README file for further details.

I have compiled a binary of mkisofs suitable for Suns running Solaris 2. Right-click on the link and select Save Link As. Then chmod 755 mkisofs and copy it to a suitable directory.

The rest of this section is only applicable if you downloaded the software from the site.

The file cdrecord-1.6.1.tar.gz contains the source code for both cdrecord and mkisofs, or you can grab a precompiled binary suitable for your system, (such as cdrecord-1.6.1-sparc-sunos5.gz). If you download the cdrecord binary, uncompress it, copy it to (for example) /usr/local/bin and make it executable:

gunzip cdrecord-1.6.1-sparc-sunos5.gz 
cp cdrecord-1.6.1-sparc-sunos5 /usr/local/bin/cdrecord
chmod 755 /usr/local/bin/cdrecord
The source code for mkisofs is also available separately in the mkisofs directory of the ftp site as mkisofs-1.12b5.tar.gz.

Even if you plan to get the binaries rather than compiling the source, you should download source so that you have the man pages and other documentation. In either case, you will need gzip to uncompress the files.

If you want to compile the programs from source, you will need a C compiler such as gcc and a make program. The 'make' that comes with Solaris 7 (/usr/ccs/bin/make) will do, GNU make is better, but Jörg Schilling's first preference is his smake which is available as source or binary (in the "bin" directory).

Untar the source and change to the cdrecord-1.6.1/DEFAULTS directory. If you're using gcc, edit Defaults.sunos5, commenting the

DEFCCOM=       cc
line and uncommenting the
DEFCCOM=        gcc
line. Also, if you want the executables installed somewhere other than /opt/schily, change the INS_BASE line to read (for example)
INS_BASE=       /usr/local
Type make to start the compilation. If all goes well, you can then type (as root) make install to copy the cdrecord and mkisofs binaries as well as the man pages to the location you selected above. See the INSTALL file in the cdrecord-1.6.1 directory for further information.
See also the CDrecord release information page.


Installing scg

You only need to do this if you are running SunOS or Solaris. It is in the form of a binary package that you install before using CDwrite for the first time. It is not included with the cdrecord tar file and must be downloaded separately from the ftp site.
The installation method for SunOS 4.1.3 is not covered here - see the appropriate README at the ftp site.

The ftp site contains 2 Solaris packages...
  SCHILYscg.i386.tar.Z   (for Intel based computers) and
  SCHILYscg.sparc.tar.Z   (for Suns).
There are also numerous updates to the actual scg driver, all having filenames starting with scg. At the time of writing (October 1999) the recommended file for Suns is scg-sparc-sol2.4.beta, even if you are running a later version of Solaris such as Solaris 7. You can ftp to and get SCHILYscg.sparc.tar.Z and scg-sparc-sol2.4.beta (make sure to use binary mode) or you can visit this site with your browser, then select the required file with your right mouse button and select "Save Link As".
A couple of important notes from the README file in the ftp site:

As described in the README file, the installation procedure for Suns is to (as root) first copy the update file to the right place, then install the package:
  cp scg-sparc-sol2.4.beta /kernel/drv/scg
  uncompress SCHILYscg.sparc.tar.Z
  tar -xvf SCHILYscg.sparc.tar
  pkgadd -d .
When asked if pkgadd should overwrite the conflicting files (i.e. the file you placed in /kernel/drv) answer with 'no'.
The screen output produced during installation may make this clearer.

Creating the Disk Image

The program mkisofs is used to create an image of the files to be recorded on the CD. A CD can hold 650 Mbytes of data, so if you are writing enough data to fill up a CD, you will need 650 - 670 Mbytes available on a hard disk to hold the disk image. Also of course, if you have more than 650 Mbytes of data, you have to choose which data to back up and which to leave out, so that the disk image you create will "fit" onto the CD.

 So far, I have always written the whole CD in one go. See the file README.multi in the cdrecord source if you want to write multi-session CDs. Another source of information is the Multi-session CD Mini Howto.

Although the type of data is irrelevant, this section shows how I use mkisofs to make a disk image of Varian Nuclear Magnetic Resonance data. On our system the NMR data is kept in a separate partition called "fids". Users have their own data directories, so the directory structure looks like this:

   /fids -+- angusfids/  dept.fid   cosy.fid   etc.
          +- harryfids/  . . .
          +- jonesfids/  . . .

and so on. To decide which data will fit onto a CD, open an Xterm, change to the /fids directory and type
  du -sk *
The output looks like this:
74284   angusfids
64735   harryfids
39349   jonesfids
2       lornafids
192562  maryfids
  (and so on)
Simply use the numbers on the left (the disk space in kbytes used by each directory) to decide which directories when backed up will consume about 650 Mbytes of disk space. If your requirements are more complex, perhaps because the data to be backed up is mixed up with other things, you may need to copy the required data somewhere before making the ISO file system.

CDs use the ISO-9660 file system. This uses the restrictive DOS-like naming convention of "up to 8 characters, followed by a period, followed by a 3 character extension". It also adds a semicolon and a file version number to the filename. So for example the name
  would become
This is not very satisfactory if backing up files from a Unix system, but mkisofs allows you to create an ISO-9660 filesystem with Rock Ridge extensions, which allows long, mixed-case filenames. I find the mkisofs documentation a bit vague concerning which, if any, of the other command-line options should be used with the "Rockridge" option. It would seem logical to assume that the "Rockridge" option overrides the -d -D -l -N -L options (see below).

The command line I now use to create the ISO file system is:

  cd /fids
  mkisofs -R -x./lornafids -x./zeusfids -o /some/disk/backup.img ./
The command line I prevously used was:
  cd /fids
  mkisofs -d -D -l -N -L -R -x./lornafids -x./zeusfids -o /some/disk/backup.img ./
Either of these will create a disk image which when written to CD, will give a normal looking Unix filesystem. If you're using it to store NMR data, Varian's Vnmr program has no difficulty reading CDs produced by either method.

 The -x options are directories to exclude, either because they are empty or contain too much data to fit on the CD. The ./ tells it to back up the current directory. If none of the disks connected to the computer have enough free space to contain the disk image, pipe the image to another computer ...

  cd /fids 
  mkisofs -d -D -l -N -L -R -x./lindafids ./ | rsh other_host "(cd /some/disk; dd of=backup.img)"
Here also, you can omit the -d -D -l -N -L options.
If you're interested, the command line options are:
    -d  omit trailing period from filenames
-D do not use deep directory relocation
-l ("ell", not "one") use long (32 character) filenames
-N omit version numbers from filenames
-L allow filenames to begin with a period
-R use Rock Ridge extensions

Writing the Disk Image to a CD

We have used 2 methods of writing the disk image to a CD.
  1. Transfer the disk image to a Macintosh, and use an application such as Toast to write the CD.

  2. We use Fetch to transfer the disk image. Make sure to use Binary transfer mode, not Automatic or Text since anything but Binary mode corrupts the disk image.
  3. Use a CD writer connected to the Sun to write the disk image.

  4. The following deals only with this second method.
Turn on your CD writer and insert a blank CD. Wait a few minutes to see if the CD is spontaneously ejected. If it is, (and your computer is running the Solaris operating system) turn off volume management by typing
  /etc/rc2.d/S92volmgt stop
and reinsert it. When you have completely finished writing your CD, turn volume management back on by typing
  /etc/rc2.d/S92volmgt start
A more permanent solution is to edit /etc/vold.conf, putting a hash at the start of the "cdrom" lines, then restart volume management using the "stop" and "start" commands above. See "README.volmgt" in the cdrecord-1.6.1 directory.

Change to the directory containing the disk image.
It is a good idea to check that your computer can supply data quickly enough to write the CD at the required speed. You do this using the -dummy argument. For example:
  cdrecord -dummy -v speed=4 dev=5,0 backup.img
...where backup.img is the name of your disk image, and dev=5,0 tells it that the CD writer occupies SCSI address 5. Change this to reflect the SCSI address of your CD writer, eg. dev=6,0
The "dummy" command above goes through the process of writing the CD, but keeps the laser turned off. If all goes well, you are ready to write the CD. Note that some drives need to eject the medium before writing a new CD. Doing a -dummy test and immediately writing a real CD would not work on these devices. Press the eject button and then reinsert the CD. If the CD is not ejected, try
  cdrecord dev=5,0 -eject

To write the CD, type something like this:
  cdrecord -v speed=4 dev=5,0 backup.img
See the man page for more usage details.

 The output should be similar to this...

Cdrecord release 1.6.1 Copyright (C) 1995-1998 Jvrg Schilling
TOC Type: 1 = CD-ROM
scsidev: '5,0'
scsibus: 0 target: 5 lun: 0
atapi: 0
Device type    : Removable CD-ROM
Version        : 2
Response Format: 2
Capabilities   : 
Vendor_info    : 'HP      '
Identifikation : 'CD-Writer 6020  '
Revision       : '1.07'
Device seems to be: Philips CDD-2600.
Using driver for Philips CDD-522 (philips_cdd522).
Driver flags   : 
Track 01: data  629 MB        
Total size:     722 MB (71:34.30) = 322073 sectors
Lout start:     722 MB (71:36/23) = 322073 sectors
Current Secsize: 2048
  ATIP start of lead in:  -11849 (97:24/01)
  ATIP start of lead out: 336075 (74:43/00)
Disk type: Cyanine, AZO or similar
Manufacturer: Taiyo Yuden Company Limited
Blocks total: 336075 Blocks current: 336075 Blocks remaining: 14002
Starting to write CD/DVD at speed 4 in write mode for single session.
Last chance to quit, starting real write in 1 seconds.
Waiting for reader process to fill input-buffer ... input-buffer ready.
Starting new track at sector: 0
Track 01: 629 of 629 MB written (fifo 100%).
Track 01: Total bytes read/written: 659601408/659601408 (322071 sectors).
Writing  time: 1154.686s
Fixating time:  126.683s
cdrecord: fifo had 10390 puts and 10390 gets.
cdrecord: fifo was 0 times empty and 10317 times full, min fill was 95%.

Verifying the CD

See the file README.verify that comes with the cdrecord source.
Whether you choose to verify the CD or not, it is a good idea to read back several files from the CD and check that they are the same as the original by doing a diff orig_file cd_file. People who backed up Varian FID data should be able to mount the CD and read datasets directly into Varian's NMR processing program to verify that the data is OK.

 The sformat program can be used to check that the data was correctly written to the CD. If the CD writer is connected to target 5 on SCSI bus 0, the command to verify the CD would be: sformat -verify 5 0

 NOTE: The README.verify file states that Not all CD-ROM drives support verifying.
This is certainly the case with our CD writer, and attempting to verify the CD with sformat just produces a stream of errors...

sformat: I/O error. verify: scsi sendcmd: no error
CDB:  2F 00 00 00 00 03 00 03 E5 00
status: 0x2 (CHECK CONDITION)
... and other messages not listed here.

 A quick check of the filesystem can be performed using star, Jörg Schilling's version of the standard Unix tar command.

Australian National University NMR Centre home page
Last modified:   7 March 2000   Chris Blake.

  • a7icJFiUjL
    By : a7icJFiUjL ( Fri Jan 12 22:50:16 2007 )

  • DVD writing
    By : anonymous ( Mon Jan 16 20:11:29 2006 )

  • Files read and write on CD
    By : anonymous ( Sat Aug 14 15:04:45 2004 )

  • Re: Writing to a DVD using a Sun Ultra 5
    By : anonymous ( Sat Feb 22 01:29:01 2003 )

  • Writing to a DVD using a Sun Ultra 5
    By : anonymous ( Fri Feb 21 15:48:02 2003 )

  • All Comments
    Name :
    Password :
    E-mail :
    Subject :
    Comments :
    English to Visayan Cebuano Dictionary
    Suggest a Site
    Visayan Cebuano to English Dictionary