Previous Section  < Day Day Up >  Next Section

Recipe 11.4. Making a Data CD for General Distribution

11.4.1 Problem

You want to create a data CD that will be readable on Linux and Windows, with non-restrictive file permissions. The disk may contain text files, documents, programs, or graphical images.

11.4.2 Solution

Use mkisofs, mount, and cdrecord. First use mkisofs to package all of the files into a single .iso file, then mount the .iso to verify the filesystem is good. Then write to disk with cdrecord.

In this example, the .iso is called data.iso, the CD is named data_disk, and all the files will be copied from the /disk-data directory. The mountpoint for the .iso is /test-iso.

Here are the commands:

# mkisofs -J -r -v -V data_disk -o data.iso  /disk-data

# mkdir /test-iso

# mount -t iso9660 -o ro,loop  data.iso /test-iso

# ls /test-iso

# umount /test-iso

# cdrecord -v -eject dev=0,1,0 data.iso

11.4.3 Discussion

This recipe shows the root user running all commands, for simplicity, because mount, mkisofs, and cdrecord require root privileges. To allow users to run the mount command, use sudo. To allow users to run mkisofs and cdrecord, create a cdrecord group. Make it own mkisofs and cdrecord, and put users in the cdrecord group.

Remember that the 2.6 kernel doesn't need IDE-SCSI, so you can just use the /dev name:

# cdrecord dev=/dev/hdc <commands>

There's a whole lot of doings packed into these few lines. Let's break them down one at a time. mkisofs takes all of your files and rolls them into one big .iso file. If you've ever downloaded a Linux distribution to burn to CD, it was packaged as an .iso file. This is a common source of confusion for Linux newbies, who don't understand why they have this giant single file, instead of a nice directory tree full of Linux files.

Let's look at the mkisofs line in more detail:

# mkisofs -J -r -v -V data_disk -o data.iso  /disk-data

Here are the options:


Use Joliet naming conventions, for Windows compatibility.


Use Rock Ridge naming conventions for Unix/Linux compatibility, and make all files publicly readable.


Use verbose mode.

-V data_disk

Create a volume ID (data_disk); this is the disc name that shows up in Windows Explorer and with the file - < /dev/scd* command (see Recipe Recipe 9.12 for how to find the /dev names).

-o data.iso /disk-data

The name of the new .iso image, and the files selected for packaging into the .iso, which in this case is everything in /disk-data. Note that the root directory /disk-data is not copied, only the contents.

Mounting the .iso before burning the disc is cheap insurance to make sure you're not creating a coaster. If you see all of your files, it's good to go. If not, the .iso is no good, and it needs to be rebuilt. Here's how to test your .iso:

# mkdir /test-iso

# mount -t iso9660 -o ro,loop data.iso  /test-iso

Then look in the /test-iso directory to verify your files.

Here are the parts of the mount command:

-t iso9660

The filesystem type. Data CDs are always iso9660 (except when they are udf, but you would not need to create an .iso image for these).

-o ro,loop data.iso

Mount options for the file data.iso: in this case read-only, using the loop device. The loop device lets you mount filesystems that are embedded in files, the classic use being .iso images.


The directory created to be the mountpoint.

Now that the .iso is all ship-shape, we can burn it to disc.

# cdrecord -v -eject dev=0,1,0 data.iso

The options are:


Be verbose.


Eject the disc when finished. This is optional.


The SCSI address of the CD writer.


The name of the .iso file that contains the files you want burned to disc.

cdrecord automatically writes at the highest speed the drive and disc support. If there are errrors, try specifiying a lower write speed:

# cdrecord -v -eject speed=4 dev=0,1,0 data.iso

Modern writers have fast write speeds (20X and higher). However, many CD-R/RW discs are limited to much slower speeds. Usually, cdrecord will auto-detect the appropriate write speed.

11.4.4 See Also

    Previous Section  < Day Day Up >  Next Section