Search the Knowledge Base:

 

Integrating a Tape Drive into a Linux System
(KB # EC49D6E3)

This document provides information for integrating MammothTape, 8mm, 4mm, and Travan tape drives into a workstation running the Linux operating system. This information is intended for use with the installation and operation instructions that accompany your tape drive.

System requirements

To use a tape drive with a Linux workstation, you need to be running the Linux kernel version 2.0.x or above.

Modifying the kernel

Make sure the Linux kernel includes support for the following items:

 

  • SCSI
  • Your host adapter
  • SCSI tape drives

To enable support for the items above:

 

  1. Log in as "root" and change to the Linux kernel source directory:

     

    system:~# cd /linux		
    
  2. Start the configuration utility system:

     

    /linux# make config	
    
  3. In the configuration options, enable support for SCSI, your host adapter, and SCSI tape drives.

     

    Note: On some systems, you can run "make menuconfig," which offers menu-driven selection.
  4. Create the file dependencies:

     

    system:/linux# make dep
    
  5. Remove the old binaries:

     

    system:/linux# make clean
    
  6. Rebuild the kernel:

     

    system:/linux# make
    
  7. Make sure the kernel compiles successfully. If necessary, correct any problems.

     

  8. Create a bootable floppy disk with the new kernel. To do this, insert a formatted floppy disk in your A: drive, then enter:

     

    system:/linux# make zdisk
    
  9. Reboot with the new kernel from floppy disk. Check your system log files for any boot-time problems. If necessary, repeat the above steps.

     

  10. If there are no problems, install the new kernel onto the system boot disk.

     

Special considerations

This section describes special considerations for using Linux with your particular tape drive.

8mm density selection

All 8mm tape drives automatically switch to the density of the inserted tape (providing the tape is written in a format supported by the drive). Therefore, you do not need to manually set the tape density for read operations.

When you need to write a tape in a specific density, use the "mt setdensity" command. For example:

 

system:~# mt -f /dev/st0 setdensity 20

According to the man pages for "mt," you should be able to use hexadecimal notation for the density (for example, "0x8c" for 8500c format). However, several versions of the "mt" command contain a bug that causes the hexadecimal value to be interpreted as 0. Use the decimal numbers below instead.

8200 format , 0x14:

 

system:~# mt -f /dev/st0 setdensity 20

8500 format, 0x15:

 

system:~# mt -f /dev/st0 setdensity 21		

8500c format , 0x8c:

 

system:~# mt -f /dev/st0 setdensity 140		

8200c format , 0x90:

 

system:~# mt -f /dev/st0 setdensity 144		

 

Block size considerations

Linux can work with tape drives in either fixed or variable mode. By default, Linux uses the default block size of your tape drive. Internally, Linux uses a 32 KB work buffer. You can control block sizes by using the "mt setblk" command. For example:

Set to 2 KB blocks:

 

system:~# mt -f /dev/st0 setblk 2048

Set to variable mode:

 

system:~# mt -f /dev/st0 setblk 0

The following are application examples:

 

  • Write to a tape drive set for 1 KB fixed mode. Linux takes the data sent by the application, divides it up in 1 KB blocks and sends a single Write Fixed command, which specifies the number of 1 KB data blocks in the work buffer.
    Example: tar sends 10 KB blocks (512 byte * default blocking factor of 20) to the Linux tape driver. The tape driver collects as many blocks as fit in the internal 32 KB buffer; so in this case, 3 blocks of 10 KB=30 KB. The tape driver then sends a single Write Fixed command, which specifies 30 blocks to be transferred.

     

  • Write to a tape drive set for variable mode. Linux uses the block size as specified by the application and uses Write Variable commands to send these blocks one by one.
    Example: tar sends 10 KB blocks to the tape driver. The driver sends each block to the tape drive using a Write Variable command and specifying 10 KB data.

     

  • Read from a tape drive set for 1 KB fixed mode. When the tape driver receives a request to retrieve a specific logical block, it calculates how many fixed mode tape blocks to request.
    Example: tar asks for 10 KB blocks. The Linux tape driver knows the drive is in 1 KB mode, so it requests a single Read Fixed command of 10 blocks.

     

  • Read from a tape drive set for variable mode. The tape driver sends a Read Variable command, asking for the size of the internal buffer of 32 KB. If it receives Check Condition status with an Illegal Length Indicator, the driver calculates how much data it received and sends that to the application.
    Example: tar asks for 10 KB blocks. The tape driver sends a read variable of 32 KB. The drive returns a block of data and posts Check Condition status. The driver retrieves the sense information and calculates that it received 10 KB of data. It passes those 10 KB on to the application.

     

You may want to exchange data between Linux and other Unix platforms (Solaris, AIX, SINIX, SCO, and so on). Most of the problems come from those platforms using a different block size. You may receive a "Tape I/O error" when trying to read those tapes, especially if your tape drive is set for 1 KB blocks and the tape contains 512-byte blocks. To solve this problem, use one of the following solutions:

 

  • If you know the block size on tape, use "mt setblk x" where x is the correct block size. This gives you the best performance.

     

  • If you do not know the block size on tape, use "mt setblk 0" to set the drive to variable mode. This gives you lower performance (only 1 block is transferred for each SCSI command, plus Check Condition overhead), but works most of the time.

     

4mm tape drives

If you have an EXB-4200c with firmware version V217 and the tape drive is attached to a Future Domain controller, you may sometimes notice hang conditions. Upgrade your tape drive to the latest firmware level. You can download new firmware from this web site.

For the EXB-4200c with firmware version V136f and higher, you can switch between compressed and non-compressed modes with the "mt setdensity" command. For example:

Compressed format, 0x43:

 

 system:~# mt -f /dev/st0 setdensity 67

Uncompessed format, 0x63:

 

system:~# mt -f /dev/st0 setdensity 99		


Rate this

Send Feedback

Send Us Feedback

Questions, comments, suggestions? Use our
feedback form and let us know what you think.

Feedback Form