home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Complete Idiot's Guide to Linux
(Publisher: Macmillan Computer Publishing)
Author(s): Manuel Ricart
ISBN: 078971826x
Publication Date: 12/22/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Extracting a File into a Device

Although creating a tar file is easy, it is not what tar is about. What’s more important is that you can extract directly into a device. The device (typically a tape drive) won’t have a file system, so it cannot be mounted or accessed in the same way that you access your disks. However, it will store the data as if it were a file. So, if you tar into a tape or floppy, the entire tape or floppy is taken to be one large tar file. (Multiple tar files can be put in a tape; I’ll talk about that in a little bit.) In the case of a floppy, you won’t be able to mount it because it won’t have a file system where you can store files. (Remember that we discussed mounting in Chapter 7, “Working with Disks.”)

Taring into a device

Taring into a device is the same as taring into a file. The only difference is that the destination of the archive is the path to the device representing your backup hardware. The basic devices that you’ll want to work with are floppies and tape drives.

Floppy Devices

To create a tar file on a floppy, you use the /dev/fdx device, where x is the number of your floppy drive. Typically, this will be 0 if you’ve got only one floppy, or 0 or 1 if you’ve got two floppies:

     tar cvf /dev/fd0 /etc /home/alberto/nsmail

This command will tar /etc and /home/alberto/nsmail into the floppy drive. It should all fit onto the backup medium; if it doesn’t, you’ll get an error. I’ll show you how to span multiple disks or tapes later in this chapter, in the section “Spanning Multiple Disks or Tapes.”

Tape Devices

Tape drives are typically hung from two different devices (your hardware might specify something else):

  st
  rft

The st devices correspond to SCSI tape drives. The rft devices correspond to tape drives that use the floppy controller or “floppy-tape” devices. (Inexpensive PC tape drives, such as QIC type drives, usually use this option.) As with other devices, there might be more than one, so the devices are differentiated from each other by the drive number they use.


Techno Talk:  
If you are using a floppy tape device, you might need to rebuild your kernel to provide support for it. If your tape drive seems to be unsupported, check out Chapter 24, “Customizing Your Linux Kernel” for information on how to do this.

The standard device files for SCSI tapes are, therefore, /dev/st0 and /dev/st1. The standard device files for the floppy-tape drives are /dev/rft0 and /dev/rft1.

So, to backup to my tape device (a SCSI drive), I enter this:

     tar cvf /dev/st0 /etc/alberto/nsmail

The default behavior of these tape devices is to rewind the tape when the write operation is finished. If your tape drive is capable of storing a few gigabytes, this could be rather wasteful, as most of the tape could remain empty. For this reason, there are nonrewinding versions of these devices that allow you to place multiple files onto one tape.

The nonrewinding tape devices are /dev/nst0 and /dev/nst1 for SCSI devices and /dev/nrft0 and /dev/nrft1 for floppy-tape devices. When you use these devices to write to the tape, the tape is not rewound, allowing you to write another archive to it. Between each file, you write to the tape so there will be a marker. You can rewind and forward the tape to your desired archive by using the mt command.

The mt Command

The mt command allows you to perform many things with a tape, including wind and rewind the tape by files (by archives it contains) using the nonrewinding device interface.

To rewind the tape, use this syntax:

     mt /dev/nst0 rewind

To wind the tape forward over the two next archives on the tape, type this:

     mt /dev/nst0 fsf 2

One trick to this command is to realize that mt has no concept of the current archive, so you’ll need to make sure that you have a list of the archives that you have on tape. Also, as a sanity check, you’ll want to make sure you are starting your count from the beginning of the tape by issuing a rewind prior to winding the tape forward.

Similarly, it is important to remember that the tape drive writes markers between different archives. This is the information that mt uses to detect different archives. After you extract data in one archive, in order to work with the other, you’ll need to forward the tape to the next archive by issuing this command:

     mt /dev/nst0 fsf 1

Whatever you do, don’t replace archives on a tape, unless you are replacing the entire contents of the tape. The one thing that you don’t want to do is overwrite the beginning of one archive by replacing a short archive with a longer one.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.