Cover V07, I12
Article

dec98.tar


Using UNIX Utilities to Create CD-ROMs

Benjamin F. Kuo

With the price of CD-writers dropping, and CD-R media at less than $2 a disk, creating your own CDs has become extremely affordable. Although most manufacturers target the PC market, most SCSI CD writers are fully usable with UNIX systems. It's easy to master your own CD-ROMs using UNIX and a SCSI CD-writer by taking advantage of the free utilities available.

Connecting the Parts

To master your own CD-ROM, you'll need a SCSI CD-writer connected to your system, CD-R media, and plenty of disk space to store the CD-ROM image before it is transferred to your CD-ROM. Almost all SCSI CD-writers can be connected to a UNIX box with a SCSI port, however, be careful that the drive you purchase is not an IDE drive - these are becoming more common because of the PC market. Find a SCSI CD-writer that is compatible with the software you are using, and connect it to your system as you would any other SCSI peripheral.

Set the SCSI ID of your CD-writer to an address not used by any of the system peripherals (disks, tape drives, etc.), and connect it to the SCSI chain. If you're unsure on how to do this, follow the instructions with the drive or your system. It's important to get the SCSI termination right - the SCSI chain should be terminated at either end of the chain but never in the middle, so check your drives and the CD-writer for the termination option and set it correctly.

Once everything is connected, you'll need to reconfigure your system to recognize the CD-writer. On a Sun Solaris system, this is a reboot with the -r option - for other systems, check your documentation. When the device files are created, the CD-writer is now visible and ready to use.

CD-R media can be purchased almost anywhere, from computer stores, mail order, to office supply stores. CD-R media is different from CD-RW media. CD-R media is meant for creating CD-ROMs, and can only be burned with an image once. CD-RW media is a more expensive read/write medium that some CD-writers support for allowing multiple writes to a disk. Support is not as good (yet) for CD-RW on UNIX systems, and not all CD-ROM drives can read CD-RW disks.

Free Utilities

As usual, the GNU project has provided some free utilities that make it possible for UNIX users to write their own CD-ROMs. mkisofs formats file system data into a form usable by CD-ROM writers (called premastering). cdwrite takes an image created by mkisofs and writes it to a CD-writer. There are also variations of these programs customized for different platforms, hooked to graphical user interfaces, or with special options available. For most basic uses, the GNU mkisofs release is usually enough. Make sure you have the latest release of the package, available from the Free Software Foundation's Web site and mirrors, and check the latest cdwrite documentation to determine which CD-writers are supported (most are).

CD-ROMs have many formats, the most basic of which is ISO9660. The ISO (International Standards Organization) has defined this specific format for CD-ROMs, which defines how filenames are stored, where and how information is stored, and how to read that information. In this specification, ISO9660 defines names in an 8+3 format, the typical MS-DOS filename.ext format. This format is readable by most systems, but doesn't allow you to take full advantage of long filenames and other features of UNIX machines.

The Rock Ridge Extension to ISO9660 is a set of additional information written to a CD-ROM, specifically for UNIX machines. These include UNIX-style long filenames, uid/gid, permissions, and device nodes. The addition of this information allows UNIX machines to access and treat CD-ROMs as any other UNIX volume, with full filenames, permissions, and other UNIX-specific file operations. However, using these extensions on a CD-ROM does not mean other non-UNIX machine types can't access the CD-ROM, it only means that other machines won't be able to take advantage of the long filenames or permissions. Long filenames will be abbreviated to the universal 8+3 filename format.

One thing to note about the Rock Ridge Extension is that long filenames on UNIX machines written with this format will not show up on other machine types that have long filenames. Long filenames on Windows or Macintosh are not stored in the same format, and require other, system-specific extensions to ISO9660 to be visible. Several variations of mkisofs also can properly format data for supporting the long filenames on Windows or Macintosh, if you need that capability.

Creating a CD-ROM

Creating a CD-ROM is usually done in two parts: premastering and the actually CD creation process, called "burning". Premastering is the process of organizing the files and data that you want to write to the CD and formatting them into a master file, which is an exact image of what will be written to the CD-ROM. The premastering program does not write the image to CD-ROM; it only prepares and formats the data for the CD-writer. Burning of the CD-ROM (so called because a laser in the CD-ROM "burns" your data into the medium) is done in the second stage by the CD-writer from a copy of your master file.

First, collect the files you want into a directory, exactly as you want them to appear on the CD-ROM. Make sure that all links are relative to this directory - absolute paths won't work once the CD-ROM has been written. Also double-check that everything is exactly as you want it, because what you see is exactly what you will get once it is written to disk. Once you've burned a CD-ROM, there's no erasing it, so a mistake at this point can be expensive. You can include subdirectories within your directory as well, as any normal filesystem would.

When all the files you want are included, in the right directories, you can create the premastered file. Using the GNU utility mkisofs, you create a master file using the following command:

mkisofs -R path -o master.iso

"Path" refers to the path of the directory in which you placed the files for mastering, and "master.iso" is the name and path to the master file. The -R enables the RockRidge extensions to the CD format, which allows the long UNIX filenames and other information. The master file should be on a fast, local disk in preparation for using the CD-writer. Remember, too, that the master file will be an exact image of the data to be written to the CD-ROM, so be sure to anticipate the amount of space required when selecting the location of this file.

Output from the mkisofs command will appear much like the following:

Total extents scheduled to be written = 17808
21.42% done, estimate finish Wed June 17 21:53:32 1999
53.13% done, estimate finish Wed June 17 21:53:30 1999
84.25% done, estimate finish June 17 21:53:33 1999
Total extents actually written = 17808
Total translation table size: 0
Total rockridge attributes bytes: 2288
Total directory bytes: 6144
Path table size(bytes): 44
Max brk space used a000
17808 extents written (34 Mb)

Additional mkisofs options that you might find useful, but that aren't absolutely necessary are:

-f - Follow symbolic links when generating the file system.

-L - Allow filenames to begin with a period (rather than substituting an underscore).

-P - Publisher_id specifies a text string with name, address, phone of the publisher of the CD-ROM.

It can take quite a while to premaster your CD-ROM, depending on how much data you have included in the directory for mastering. Once you've successfully premastered your CD-ROM, you're ready to burn the CD from the master.iso file. This file now contains the entire image, formatting and all, that will be burned onto the CD-R disk.

It's important when you're burning your CD-ROM to make sure that the master data file can be read quickly. Always burn the master file from a local disk, and make sure the system on which you're creating the CD-ROM isn't too heavily loaded.

When you're ready to create the actual CD-ROM, use the cdwrite program to test out the CD-writer. The -y option in cdwrite allows a "simulated run", which transfers the data to the CD-writer and tests for buffer underruns and other conditions that can ruin your CD-ROM. Run this by typing:

cdwrite -evy -s 4 master.iso /dev/your_CDR_device

The option -e specifies to eject the CD-ROM when writing is complete. -v will give verbose output; -s 4 specifies the CD-writer to write at 4x speed (dependent on your CD-Writer), so you have a better idea of what's occurring. This can take anywhere from 2 to 10 minutes, depending on the amount of data to be written to disk. You can tell that this is a simulated run, because the CD-writer will not light up the "burn" or "writing" light. If this runs okay, you can do the actual CD creation by not including the -y option, like the following:

cdwrite -ev -s 4 master.iso /dev/your_CDR_device

This is the actual write process. During the write process, the "burn" or "write" light on your CD-writer will be lit. When this is running, it's best not to be running any heavy loads on your machine, or log in and out of your system. This might slow down the ability of the system to keep the CD-writer supplied with data, which could ruin the CD-ROM. The burn process takes the same 2 to 10 minutes that the simulated run did.

Finally, when this is complete, you have your CD-ROM. The last thing to do is to mount the CD-ROM you just created on another machine. Check through your directories and look at a few files to make sure everything looks okay, and you've successfully created a CD-ROM disk on your UNIX machine.

In addition to burning CD-ROMs directly from UNIX, most PC programs will also accept the ISO9660 format (.iso file). Even if you don't have a CD-writer attached to your UNIX box, if you have a PC with a CD-writer on your network, you can easily transfer your premastered file (master.iso in the above example) to that PC for burning.

Avoiding Coasters

"Coasters" are CD-ROMs that are unusable except as drink coasters - the product of a CD-ROM burn gone awry. Some common pitfalls you might encounter, and how to avoid them, when you're creating your own CD-ROMs include:

Running out of disk space - Keep in mind that premastered files for a CD-ROM could occupy as much as 650MB (the capacity of a CD). Make sure you have enough room to store this on your file system.

Wrong (8+3) filenames - Make sure you have the right switches set in your premastering program to generate the Rock Ridge extensions; otherwise the filenames will be incorrect once you've generated your CD-ROM.

Failed to write CD-image - Speed of the disk where your premastered file is stored can cause CD-writer errors, because it may not be able to read the premastered file fast enough. Make sure your premastered file is stored on a fast SCSI disk (usually, NFS-mounted volumes are too slow to handle the amount of data required by a CD-writer). Because of the way CD-writers work, once a track has begun to be written, the writer can't stop. It is therefore very important that the CD-writer's buffer never runs out of data. This may require you to limit the load on the machine on which you're burning the CD-ROM, and to make sure the disk on which the master is stored is also a fast one (SCSI disks are the best).

Common causes of write failures include:

  • Dirty media - Make sure there is no dust on the disk before you burn, and that the CD-writer lens is clean. If there is interference during writing, the disk will not be usable.

  • System load too high - Logging in and out of the system console, heavy filesystem activity, or other CPU load can cause the same problems as a slow disk. Errors delaying data transfer from your master to the CD-writer can results in a write failure, which will ruin your CD-ROM. Make sure the system you're writing the CD in is dedicated, or is not subject to heavy loads.

By knowing what the most common problems are with writing CD-ROMs, you should be able to minimize the amount of wasted CD-R media.

Commercial Programs

In addition to the free utilities available for premastering and creating your own CD-ROMs, there are several commercial programs. These programs have the advantage of graphical user interfaces for organizing and indexing your files, the ability to handle multiple CD-ROM formats, hybrid disks (disks readable by UNIX, PCs, and Macs), digital audio, and mixed data/audio disks, Depending on your needs, you might want to look into using a commercial product with more features.

CD-ROMs are ideal for creating your own software releases, archiving data, or backing up files. With cheap CD-writers and CD-R media, it's very affordable to create and distribute your own CD-ROMs. By using the free utilities and watching out for the pitfalls, you can easily create your own CD-ROMs on a UNIX machine.

Resources

mkisofs and cdwrite packages for various UNIX and other platforms can be found on many of the mirrors of the GNU software site, located at:

http://www.gnu.ai.mit.edu/

Commercial programs:

Elektroson GEAR:

http://www.elektroson.com

Creative Digital Research HyCD:

http://www.cdr.com

About the Author

Benjamin F. Kuo is a software engineer working in Westlake Village, California, writing device drivers for various platforms. He can be reached at kuokuo@concentric.net.