11.3. CD-Rs and CD-RWs

CD-writable (CD-R) drives have grown in popularity as an inexpensive way to backup and archive several megabytes of data, including applications, personal files, and even multimedia (audio/video and still image) presentations. Red Hat Enterprise Linux includes several tools for using CD-Rs and CD-rewritable (CD-RW) drives.

11.3.1. Using CD Creator

If you want to perform a quick file or directory backup to a CD-R or CD-RW, there is a tool included in the Nautilus file manager called CD Creator.

CD Creator allows you to drag and drop files from a Nautilus window to the CD Creator interface. To access the CD Creator feature in Nautilus, insert a blank CD-R(W) into your drive and the CD Creator window will automatically display. You can also double click your home directory icon from the desktop and choose Go => CD Creator from the window menus. You can also type burn: in the Location bar to start CD Creator.

Figure 11-5. The CD Creator Interface in Nautilus

Open a new Nautilus window and select the files or directories you want to write to CD-R(W). To select multiple files, press and hold the [Ctrl] key, and click on the files and folders. Then release the [Ctrl] key, press and hold the left mouse button, and drag the files and folders to the CD Creator window.

When you are ready to write the files to your CD-R(W), click the Write to CD button in the CD Creator window, which displays a dialog box where you can select the writing speed, name the CD, and choose other options.

Figure 11-6. The CD Creator Write Dialog Box

Click the Write files to CD button to start burning. A status window displays the writing progress, as shown in Figure 11-7.

Figure 11-7. The CD Creator Write Status Window

By default, the CD-R(W) should automatically eject from your drive when it is finished. Since it is generally recommended to periodically backup personal files, the CD Creator can help you do so quickly.

11.3.2. Using CD-Rs and CD-RWs with Command Line Tools

If you want to use a shell prompt to write images to CD-R or CD-RWs, there are two utilities available: mkisofs and cdrecord. These utilities have several advanced options that are beyond the scope of this guide; however, for basic image creation and writing, these tools save some time over the graphical alternatives such as X-CD-Roast. Using mkisofs

The mkisofs utility creates ISO9660 image files that can be written to a CD-R(W). The images created by mkisofs can include all types of files. It is most useful for archival and file backup purposes.

Suppose you wish to backup a directory called /home/joeuser/, but exclude the subdirectory /home/joeuser/junk/ because it contains unnecessary files. You want to create an ISO image called backup.iso and write it to CD-R(W) so that you can use it on your Red Hat Enterprise Linux PC at work and your Windows laptop for trips. This can be done with mkisofs by running the following command:

mkisofs -o backup.iso -x /home/joeuser/junk/ -J -R -A -V -v /home/joeuser/

The image is created in the same directory that you ran the command. Table 11-1 explains each command line option. For more information on using mkisofs, refer to the additional resources in Section 11.4 Additional Resources.

You can now use the ISO image file with cdrecord, the command line based CD recording utility. For more information about using cdrecord, refer to Section Using cdrecord.

-oSpecifies an output file name of the ISO image.
-JGenerates Joliet naming records; useful if the CD is used in Windows environments.
-RGenerates Rock Ridge (RR) naming records to preserve filename length and casing, especially for UNIX/Linux environments.
-ASets an Application ID — a text string that will be written into the volume header of the image which can be useful to determine what applications are on the CD.
-VSets a Volume ID — a name that is assigned to it if the image is burned, and the disc is mounted in Solaris and Windows environments.
-vSets verbose execution, which is useful for viewing the status of the image as it is being made.
-xExcludes any directory immediately following this option; this option can be repeated (for example, ... -x /home/joe/trash -x /home/joe/delete ...).

Table 11-1. mkisofs Options Using cdrecord

The cdrecord utility writes audio, data, and mixed-mode (a combination of audio, video, and/or data) CD-ROMs using options to configure several aspects of the write process, including speed, device, and data settings.

To use cdrecord, you must first establish the device address of your CD-R(W) device by running the following command as root at a shell prompt:

cdrecord -scanbus

This command shows all CD-R(W) devices on your computer. It is important to remember the device address of the device used to write your CD. The following is an example output from running cdrecord -scanbus.

Cdrecord 1.8 (i686-pc-linux-gnu) Copyright (C) 1995-2000 Jorg Schilling
Using libscg version 'schily-0.1'
	0,0,0     0) *
	0,1,0     1) *
	0,2,0     2) *
	0,3,0     3) 'HP      ' 'CD-Writer+ 9200 ' '1.0c' Removable CD-ROM
	0,4,0     4) *
	0,5,0     5) *
	0,6,0     6) *
	0,7,0     7) *

To write the backup file image created with mkisofs in the previous section, switch to the root user and type the following at a shell prompt:

cdrecord -v -eject speed=4 dev=0,3,0 backup.iso

The command sets the write speed (4), the device address (0,3,0), and sets write output (verbose [-v]), which is useful for tracking the status of the write process. The -eject argument ejects the CD-ROM after the write process is complete. The same command can also be used for burning ISO image files downloaded from the Internet, such as Red Hat Enterprise Linux ISO images.

You can use cdrecord to blank CD-RW discs for reuse by typing the following:

cdrecord --dev=0,3,0 --blank=fast