Selecting a Backup Medium

Selecting a Backup Medium

Armed with a backup strategy in mind, it is time to select a backup medium. Several types of backup hardware and media are available for use with Red Hat Linux. Each type has its advantages and disadvantages.

The type of medium to choose depends largely on the amount of data you need to archive, how long you will store backups, how often you expect to recover data from your backups, and how much you can afford to spend. Table 13-1 compares the most common backup media.

Table 13-1: Comparison of Common Backup Media

Backup Medium



Magnetic tape

High capacity, low cost for archiving massive amounts of data.

Sequential access medium, so recovery of individual files can be slow.

Writable CDs

Random access medium, so recovery of individual files is easier. Backups can be restored from any CD-ROM.

Limited storage space (approximately 650MB per CD).

Writable DVD

Random access medium (like CDs). Large capacity (4.7GB, although the actual capacity you can achieve might be less).

DVD-RW drives and DVD-R disks are relatively expensive (though coming down in price). Slower and less common than CD-ROM drives.

Additional hard drive

Allows faster and more frequent backups. Fast recovery from crashes. No media to load. Data can be located and recovered more quickly. You can configure the second disk to be a virtual clone of the first disk, so that you can boot off of the second disk if the first disk crashes.

Data cannot be stored offsite, thus there is risk of data loss if the entire server is destroyed. This method is not well suited to keeping historical archives of the many revisions of your files. The hard drive will eventually fill up.

The following sections describe how to use magnetic tape, writable DVDs, and writable CDs as backup media. How to use additional hard drives as backup media is described later in this chapter.

Magnetic tape

Magnetic tape is the most common medium used for backing up large amounts of computer data. Tapes provide a low-cost, convenient way to archive your files. Today's high-capacity tape drives can back up many gigabytes of data on an amazingly small tape, allowing vast amounts of information to be safely stored.

The primary disadvantage of magnetic tape is that it is a sequential access medium. This means that tapes are read or written from beginning to end, and searching for a particular file can be time-consuming. For this reason, tape is a good choice for backing up and restoring entire file systems, but not the ideal choice to recover individual files on a regular basis.

Red Hat Linux can use a wide variety of tape drives. Most SCSI tape drives will work with the generic Linux kernel. Even many IDE tape drives are supported via a "SCSI emulation" mode. Some drives, however, require installation of additional software.

Using ftape tools for magnetic tape

If your tape drive is attached to an IDE floppy controller cable, you will need to use the ftape driver to access it. Fortunately, version 3.04d of the ftape loadable module is bundled with the Linux 2.4 kernel. When your Linux system boots, it should autodetect the tape drive and load the ftape driver. To verify that your system loaded the tape driver, type the following command shortly after you boot your computer:

dmesg | grep ftape

This searches the most recent kernel messages for lines containing the word ftape. If the ftape module was loaded, you should see something like this:

ftape v3.04d 25/11/97
[000] ftape-init.c (ftape_init) - installing QIC-117 floppy tape
hardware drive... .
[001] ftape-init.c (ftape_init) - ftape_init @ 0xd08b0060.
[002] ftape-buffer.c (add_one_buffer) - buffer nr #1 @ c1503914, dma
area @ c02c0000.
[003] ftape-buffer.c (add_one_buffer) - buffer nr #2 @ c1503c44, dma
area @ c0298000.
[004] ftape-buffer.c (add_one_buffer) - buffer nr #3 @ c50abaac, dma
area @ c0328000.
[005] ftape-calibr.c (time_inb) - inb() duration: 1109 nsec.
[006] ftape-calibr.c (ftape_calibrate) - TC for `ftape_udelay()' = 310
nsec (at 20479 counts).
[007] ftape-calibr.c (ftape_calibrate) - TC for `fdc_wait()' = 2208 nsec
(at 2559 counts).

If the module was not loaded, then you should check if your kernel is compiled with support for the ftape module and your particular tape drive. Refer to the section on reconfiguring the kernel located in Appendix A. When running the make config or make xconfig command, choose Character Devices ? ftape, the floppy tape device driver. You can then verify that the ftape module is enabled and that your specific hardware is supported. Continue with compiling and installing the kernel in the normal way.

In most cases, an ftape device can be accessed just like a SCSI device. The primary difference is that an ftape device file contains the letters qft (for QIK Floppy Tape) where a SCSI tape contains st. For example, the device file for the first SCSI tape on your system will probably be /dev/st0; the device file for the first floppy tape will likely be /dev/qft0.

All of the standard tape and archiving related programs should work fine with both types of hardware. Nevertheless, there are a few extra programs that you may find useful when working with a floppy tape drive. These programs can be found in the ftape-tools package located at Download the file named ftape-tools-1.09.tar.gz. If a version higher than 1.09 is available, download that instead. Extract the ftape package using the tar command:

$ tar -xzvf ftape-tools-1.09.tar.gz

This extracts the package into an ftape-tools-1.09 directory. Use the cd command to go to that directory and to run the ./configure script to prepare the package's makefiles. Next, compile the package by typing the make command:

$ ./configure
$ make

Finally, assume root privilege using the su command and type make install to install the ftape-tools programs and online man pages to the appropriate directories:

# make install

Testing the magnetic tape drive

You should now be ready to test your tape drive. Insert a blank tape into the tape drive and type the following command:

$ mt -f /dev/qft0 rewind

You should hear the tape spin as the system rewinds the tape. This will be a very short process if the tape is already rewound. The mt command provided with ftape-tools is used to scan, rewind, and eject magnetic tapes in a floppy controller tape drive. It is very similar in operation to the st command, which is used to perform the same functions on SCSI tapes.

Formatting magnetic tapes

The ftape-tools package also includes a tool for formatting tapes as well. Most tapes now come preformatted. In the event that you have an older floppy controller tape drive that uses unformatted tapes, use the ftformat command to format them:

$ /usr/local/bin/ftformat -f /dev/qft0

Usually, the -f parameter with the device name is the only parameter that you need to supply. Nevertheless, you are encouraged to read the online man page for ftformat to learn more about its options and capabilities.

Writable CD-ROM drives

Another backup medium that is gaining popularity is the writable CD-ROM drive. Writable CD-ROM drives have several advantages over tape, the primary one being that CDs are a random access medium. This means that the CD drive can quickly locate a particular file on the CD without sequentially scanning through the entire disc. This is useful when you need to keep a revision history of frequently changing data files (such as source code for a software project or drafts of legal documents).

Another advantage is the extremely long life span of CDs. If you wish to archive your backups for a very long time, a writable CD drive is a good choice. If your backups are intended for short-term storage, you should probably consider a rewritable CD drive. A rewritable CD (unlike plain writable CDs) can be reformatted and used to store new backups.

The biggest drawback is that a CD can store at most about 650MB of data. In contrast, DVDs can store 4.7GB of data and many tape drives can store multiple gigabytes of data. For example, DAT DDS-3 tapes can hold up to 24GB of compressed data, while 8mm AIT-2 tapes can hold up to 100GB of compressed data.

Getting cdrecord for writable CDs

To write CDs with Red Hat Linux you need to install the cdrecord package. This package contains components such as the cdrecord, devdump, isodump, isoinfo, isovfy, and readcd commands. The cdrecord package is included with the Red Hat Linux distribution.


The cdrecord package requires that you use a SCSI CD drive. If you have an IDE/ATAPI CD drive, which is a very popular device, you may need to configure that drive to do SCSI emulation. For the latest versions of Red Hat Linux, however, SCSI emulation is usually taken care of automatically. See Chapter 8 for a description of how to configure an IDE/ATAPI CD drive for SCSI emulation.

Writing to CDs

Because the data written to a CD becomes permanent once it is written, you need to format the CD and copy files to it all in one step. If you formatted it first, you would end up with an empty file system on a CD that can no longer be written to.

The first step is to create an image of the CD file system as a file on your computer. You do this with the mkisofs command. As an example, imagine that you want to back up the home directory for user mary. You would invoke the mkisofs command and pass it the name of the file system image file to create, followed by the directory to base it on:

$ mkisofs -R -o /var/tmp/ /home/mary

This creates an ISO9660 file system image in a file named located in the /var/tmp directory. The –R option causes Linux-specific file ownership and long file names to be used. If your /var partition does not have enough room for the image, choose a different location.


By default, mkisofs preserves the ownership and access rights of files and directories when it creates the file system image. This is appropriate when you are making a backup, but not when you are creating a software distribution CD. In such a case, add the -r option instead of -R as the first parameter to mkisofs. It will then store all files as publicly readable and, where appropriate, executable.

Before you can write this image file to a CD, you must first discover the SCSI bus number, device ID number, and Logical Unit Number (LUN) of the CD drive. Unless you have an actual SCSI bus in your computer, the emulated SCSI bus is probably numbered zero. You can find out which SCSI device ID the CD drive is using. Invoke the cdrecord command with the single parameter -scanbus:

# cdrecord -scanbus

You should see a response similar to the following:

Cdrecord 2.0 (i686-pc-linux-gnu) Copyright (C) 1995-2002 J?rg Schilling
Linux sg driver version: 3.1.25
Using libscg version 'schily-0.7'
        0,0,0     0) 'IDE-CD ' 'R/RW 4x4x24  ' '1.04' Removable CD-ROM
        0,0,1     1) *
        0,0,2     2) *
        0,0,3     3) *
        0,0,4     4) *
        0,0,5     5) *
        0,0,6     6) *
        0,0,7     7) *

This tells you that the CD drive is using SCSI ID zero. The Logical Unit Number in this case should always be zero, so you now have all three numbers. You supply them to cdrecord as part of the dev parameter. The SCSI bus number is listed first; it is followed by the ID number, and then by the LUN. The entire command should look similar to this:

# cdrecord -v speed=2 dev=0,0,0 -data /var/tmp/

Several additional parameters are included in the command. The -v parameter tells cdrecord to supply verbose output to the screen. The speed parameter tells cdrecord what speed to record at (in this case X2). (You might choose to leave off speed=2 and let cdrecord autodetect the record speed of your CD burner.) The -data parameter tells cdrecord that the next parameter is the name of the file system image to write to the CD. (You can add the -eject to eject the CD when it is done.) As it works, cdrecord should display status messages that look similar to the following:

Cdrecord 2.0 (i686-pc-linux-gnu) Copyright (C) 1995-2002 J?rg Schilling
TOC Type: 1 = CD-ROM
scsidev: '0,0,0'
scsibus: 0 target: 0 lun: 0
Linux sg driver version: 3.1.24
Using libscg version 'schily-0.7'
atapi: 1
Device type    : Removable CD-ROM
Version        : 0
Response Format: 1
Vendor_info    : 'IDE-CD'
Identifikation : 'R/RW 4x4x24        '
Revision       : '1.04'
Device seems to be: Generic mmc CD-RW.
Using generic SCSI-3/mmc CD-R driver (mmc_cdr).
Driver flags   : MMC SWABAUDIO
Supported modes: TAO PACKET RAW/R16
Drive buf size : 1572864 = 1536 KB
FIFO size      : 4194304 = 4096 KB
Track 01: data   322 MB
Total size:     370 MB (36:43.12) = 165234 sectors
Lout start:     370 MB (36:45/09) = 165234 sectors
Current Secsize: 2048
ATIP info from disk:
  Indicated writing power: 4
  Is not unrestricted
  Is not erasable
  Disk sub type: Medium Type A, high Beta category (A+) (3)
  ATIP start of lead in:  -11849 (97:24/01)
  ATIP start of lead out: 359848 (79:59/73)
Disk type:    Long strategy type (Cyanine, AZ0 or similar)
Manuf. index: 25
Manufacturer: Taiyo Yuden Company Limited
Blocks total: 359848 Blocks current: 359848 Blocks remaining: 194614
Starting to write CD/DVD at speed 2 in real TAO mode for single session.
Last chance to quit, starting real write in 0 seconds. Operation starts.
Waiting for reader process to fill input buffer ... input buffer ready.
Performing OPC...
Starting new track at sector: 0
Track 01:  322 of  322 MB written (fifo 100%)  [buf  99%]   2.0x.
Track 01: Total bytes read/written: 338395136/338395136 (165232 sectors).
Writing  time:  1110.710s
Average write speed   2.0x.
Fixating time:  126.108s
cdrecord: fifo had 5331 puts and 5331 gets.
cdrecord: fifo was 0 times empty and 5262 times full, min fill was 96%.

After cdrecord finishes writing the CD and your shell prompt returns, delete the file system image file /var/tmp/ Label the CD appropriately and store it in a safe place.

If you need any files that were copied to the CD, just return the CD to the CD drive. If it doesn't automatically open a window displaying the contents of the CD, type: mount /mnt/cdrom as root user. Open /mnt/cdrom in a folder window and copy the files you want.


See Chapter 8 for more information on cdrecord. You can also learn more about installing and troubleshooting writable CD drives from the CD-Writing-HOWTO. Or you can get a copy of the HOWTO by visiting the Linux Documentation Project Web site,

Writable DVD drives

Using a writable DVD drive and the dvdrecord command, you can back up your data to DVD-R disks. The procedure is almost identical to backing up data onto a CD-ROM, with the following exceptions:

  • You use the dvdrecord command instead of cdrecord (although they both have nearly identical interfaces).

  • Each backup disk can hold a lot more data (4.7GB compared to 700MB).

  • Both the DVD writer and medium are more expensive than the CD counterparts.


    When manufacturers say 4.7GB, they are talking about 1000MB per GB, not 1024MB. Therefore, you can really only store up to about 4.4GB of data on a DVD.

The dvdrecord command should allow you to burn DVDs on any DVD burner that is compliant with the Multimedia Command (MMC) standard. Development of the dvdrecord command was done on a Pioneer DVR-A03 DVD writer.

Follow the procedure in the "Writable CD-ROM drives" section to create a file system image file (using mkisofs) and determine the location of your DVD-R driver. Then use the dvdrecord command to actually burn the DVD. Here is an example of a dvdrecord command line that burns a file system image called

# dvdrecord -v speed=2 dev=0,0,0 -data

Part IV: Red Hat Linux Network and Server Setup