📄 lsg12.htm
字号:
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<LINK REL="ToC" HREF="index.htm">
<LINK REL="Index" HREF="htindex.htm">
<LINK REL="Next" HREF="lsg13.htm">
<A NAME="I0"></A>
<H2>Linux System Administrator's Survival Guide lsg12.htm</H2>
<P ALIGN=LEFT>
<HR ALIGN=CENTER>
<P>
<UL>
<UL>
<UL>
<LI>
<A HREF="#E68E67" > SCSI Tape Drives</A>
<LI>
<A HREF="#E68E68" >The ftape Program</A>
<LI>
<A HREF="#E68E69" >Using the Tape Drive</A>
<LI>
<A HREF="#E68E70" >Summary</A></UL></UL></UL>
<HR ALIGN=CENTER>
<A NAME="E66E14"></A>
<H1 ALIGN=CENTER>
<CENTER>
<FONT SIZE=6 COLOR="#FF0000"><B>Chapter 12</B></FONT></CENTER></H1>
<BR>
<A NAME="E67E17"></A>
<H2 ALIGN=CENTER>
<CENTER>
<FONT SIZE=6 COLOR="#FF0000"><B>Tape Drives</B></FONT></CENTER></H2>
<BR>
<P>A tape drive is one of the most important devices you can own because it provides you with an easy way to back up your work. Tape drives have dropped in price to the point where anyone can afford them, especially the floppy tape-driven units that are becoming widespread.
<BR>
<P>Installing a tape drive is usually not difficult, but you will need a device driver for it. Many manufacturers of tape drives don't bother with Linux (or UNIX) when it comes to drivers, instead opting to concentrate on the lucrative DOS market. The DOS drivers cannot be used with Linux.
<BR>
<P>Instead, carefully check the tape unit before you purchase it, if you intend to use it for Linux. In general, SCSI tape devices are supported, as are most tape drives that use the floppy interface. When this chapter was written, no drivers were yet available (although they were being developed) for tape drives that use the parallel port. This chapter looks at the types of tape drives you can use with your Linux system. It also explains how to use ftape, the most popular QIC tape unit control software.
<BR>
<BR>
<A NAME="E68E67"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B> SCSI Tape Drives</B></FONT></CENTER></H3>
<BR>
<P>Except for the SCSI drives that use special tape encoding, practically all SCSI tape drives (of any size and capacity of tape) work with Linux. Installing a SCSI tape drive is the same as installing any other SCSI device; you must set a unique SCSI ID for the drive and plug the drive into the SCSI chain. Several SCSI tape device drivers are available for Linux, all of which have slightly different target machines or markets. Select a device driver from those provided on your distribution media or the FTP or BBS sites and link it into the kernel.
<BR>
<P>The SCSI tape driver usually has a major device number of nine and a minor number of zero. The devices are usually called /dev/nrst0 (for a non-rewind device) and /dev/rst0 (for a rewind device). Check the /dev directory to see whether entries for these devices already have been created. The command
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">ls /dev/*rst*</FONT></PRE>
<P>lists all the SCSI tape devices. If no devices are present, you must make them with the commands
<BR>
<PRE>
<FONT COLOR="#000080">mknod -m 666 /dev/nrst0 c 9 9
mknod -m 666 /dev/rst0 c 9 0</FONT></PRE>
<P>These commands create device files for the rewind (rst) and non-rewind (nrst) drivers with the major number nine and the minor number zero. The file permissions are set to 666 (see <A HREF="lsg17.htm">Chapter 17</A>, "System Names and Access Permissions").
<BR>
<P>Once the device drivers have been created, you can begin using the tape drive. Specific tape parameters such as the length of blocks, buffers, tape density, and so on, are usually set with the mt program or through the tar command. There are two versions of the mt command generally distributed with versions of Linux, and the usage of these commands differs notably. Check your man pages or on-line help to find the proper syntax to set the block size and other parameters. For example, usually you can set the tape drives block size with the command
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">mt setblk 20</FONT></PRE>
<P>which sets the block size to 20. If you want to use variable length blocks on your tape drive (make sure the drive supports them), use the command
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">mt setblk 0</FONT></PRE>
<P>If you get error messages with the version of mt included with your Linux system, the version is probably the GNU version. This version does not allow you to set such parameters, so you should get the BSD-derived mt version instead.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>If your SCSI tape drive isn't recognized when Linux boots (and the tape device has been properly configured), reboot the machine with a tape in the tape drive. The activity of tensioning the tape usually lets Linux know that the tape device is on the SCSI chain.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>You can verify that the Linux kernel has found your SCSI tape drive properly by examining the boot messages. (Use the dmesg command to replay the boot messages.) You see lines similar to the following if the SCSI tape drive is recognized:
<BR>
<PRE>
<FONT COLOR="#000080">aha274x: target 4 now synchronous at 4.4Mb/s
Vendor: TANDBERG Model: TDC 3800 Rev: =05:
Type: Sequential-Access ANSI SCSI revision: 02
Detected scsi tape st0 at scsi0, id 4, lun 0
scsi : detected 1 SCSI tape 1 SCSI cdrom 1 SCSI disk total.</FONT></PRE>
<P>The tape drive's electronics provide Linux with the name and type of tape drive, as do most SCSI devices.
<BR>
<BR>
<A NAME="E68E68"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>The ftape Program</B></FONT></CENTER></H3>
<BR>
<P>The ftape program is a tape device interface meant for QIC-117, QIC-40, and QIC-80 drives only. Both QIC-40 and QIC-80 tape drives connect through the floppy drive controller cable, so if your tape drive is not connected throught the floppy drive cable, you probably cannot use ftape.(Sometimes the floppy cable is routed to another hardware board mounted in the PC expansion chassis and then to the tape drive. Some of these drives work with ftape and others do not.)In general, you cannot use ftape with tape drives that connect to the parallel port. You cannot use the ftape program with SCSI or QIC-02 tape drivers or some of the newer compression-based small cartridge drives either. If you're not sure whether the ftape program will work with your tape drive, experiment. All you will use up is time.
<BR>
<P>One caveat with current versions of ftape is that you cannot format a tape under Linux. Instead, you must either purchase preformatted tapes or boot into DOS (even if from a floppy disk) and run a utility program, usually supplied with the tape drive, to format the tape cartridges.
<BR>
<P>If you installed Linux from a setup routine on a CD-ROM, you probably were given the option of installing ftape at that time. The kernel may already be linked in for you. If you are using Linux version 0.99p114t or later, ftape is probably linked in. You can verify whether ftape is active on your system by examining the system boot messages (use dmesg to show the messages) for a line like the following:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">ftape: allocated 3 buffers aligned at: 00220000</FONT></PRE>
<P>You see this message with later Linux kernels even if you have only a SCSI tape drive.
<BR>
<P>If the driver is not linked in, either extract the files from your distribution media or obtain the latest version of ftape from the FTP or BBS sites. If you can only get source code for the ftape program, you will also need a compiler. The software distribution package for ftape should include a complete installation file that you can follow. This section looks at the general process of installing ftape in a little detail.
<BR>
<P>The ftape device driver must be installed in the /dev directory and linked into the Linux kernel to be active. After you have obtained the full ftape distribution software, copy the files to a subdirectory for ftape. Check the /dev directory for an existing ftape device with the command
<BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -