KB Logo

TOLIS Group Knowledge Base

Browse KB by category:
Go to KB #:
Glossary
Email   Bookmark



How do I control tape devices with tapectl(tm)?

Views: 17074
Votes: 0
Posted: 15 Oct, 2007

Controlling Tape Drives - tapectl

Tape drives control their media in one of two manners - rewinding mode and non-rewinding mode. In rewinding mode, the media is opened, if the media is not at its beginning, it is rewound, the user operation is performed, and the media is rewound to its beginning. In non-rewinding mode, the media is opened wherever it is positioned, the operation is performed, and the media position remains where the last command left it. The first mode is useful only for writing or reading a single data set from the beginning of the media. The second mode allows much greater flexibility in how a tape is used.

All of the TOLIS Tape Tools utilities use the non-rewinding mode of access.

The tapectl utility provides the following tape operations:

display - displays information on all available tape devices
inquiry - displays SCSI inquiry details for the selected drive
status - display current drive status
fsf x - forward space filemark (x = count; 1 is default)
bsf x - back space filemark (like fsf, but backwards)
seod - space to end of data for appends
erase - short erase a tape
lerase - long (secure) erase - takes hours!
rewind - rewinds a tape
rewoff - rewind the tape and unload it
reten - retention a tape (QIC and TRAVAN tapes)
tell - report current logical tape block
seek x - seek to logical tape block 'x'
setblk x - set drive block size to x (x is required, 0 = variable block)
alert - display Tape Alert information (if supported and available)
unload - same as rewoff

Example tapectl Commands and Their Results

# tapectl -f ntape0 display
Available Tape Devices:
ntape0: IBM ULTRIUM-TD1 25D4
ntape1: IBM ULTRIUM-TD1 25D4

# tapectl -f ntape1 inquiry
Vendor = IBM , Model = ULTRIUM-TD1
Revision Level = 25D4

# tapectl -f ntape1 status
Medium Type: Unknown
Density Code: 0x40 - DLT1 40 GB , or LTO 1
BlockSize: 0
At block 55259

Most other tapectl commands perform their operations silently with the return code of the command indicating success or failure.

# tapectl -f ntape1 rewind
# echo $?
0

This return code (or exit code) of zero indicates that the rewind was successful. Any non-zero return code indicates an error occurred. In most instances, an error will also return text details if the -v (verbosity) option is included in the command:

# tapectl -f ntape0 -v erase
Erasing media in drive ... Device Not Ready, No tape inserted
# echo $?
2

The return code from this command was 2, and the error message indicates that we attempted to perform a tape operation, but no tape was in the drive.

The following commands can be issued when no tape is in the drive with successful results:

display, inquiry, status, setblk, and alert 

All other tapectl commands will return an error if there is not tape in the drive.

tapectl Command Breakdown

display
Syntax: tapectl display

The display command searches all busses on your system and reports any type 1 SCSI devices that are located. These devices can be SCSI, Fibre-Channel, Firewire , or USB. We use a naming convention of ntapeX – where X is a number starting at zero. The default tape device for all command is ntape0.

inquiry
Syntax: tapectl inquiry

The inquiry command issues a SCSI INQUIRY command to the defined device and displays the data returned by the tape drive.

status
Syntax: tapectl status

The status command gets information from the tape drive and reports the load status, data block size, current block and any SCSI sense messages.

fsf
Syntax: tapectl fsf 4

The fsf, or Forward Space Filemark command moves the tape forward from its current position to the next filemark. The tape is left positioned on the end of tape (EOT) side of the filemark ready to read of write. You can specify multiple filemarks by providing a number argument after the fsf command.

bsf
Syntax: tapectl bsf 2

The bsf, or Back Space Filemark command moves the tape backwards from its current position to the previous filemark. The tape is left at the EOT side of the filemark. You can specify multiple filemarks by providing a number argument after the bsf command.

seod
Syntax: tapectl seod

The seod, or Space to End Of Data command moves the tape forward to the end of currently recorded data. This allows you to position the tape in preparation for writing additional data.

erase
Syntax: tapectl erase

The erase command uses the SCSI short erase function to clear the contents of the tape. The short erase simply blanks the header on the tape and writes an end of data (EOD) marker at the beginning of the tape. It does not physically erase any data that was previously written on the tape.

lerase
Syntax: tapectl lerase

The lerase, or Long Erase command actually erase all data on the tape before resetting the EOD marker. While this erase method is more secure than the short erase above, it can take a very long time for a long erase to complete. For example, a 230M SDX3-100 AIT3 tape will take almost 5-1/2 hours to complete the long erase. A DLT VS80 tape will take a little over 2 hours. For most environments, the short erase provides enough security as it takes a specially modified tape drive to read beyond the EOD marker.

rewind
Syntax: tapectl rewind

The rewind command returns the tape to its beginning.

rewoff
Syntax: tapectl rewoff

The rewoff, or Rewind Offline command rewinds the tape and ejects it from the drive.

reten
Syntax: tapectl reten

The reten command is only useful for QIC or TRAVAN tape mechanisms. These tapes sometimes require retentioning to reset the tape travel path within the cartridge shell. If you are having problems reading a known good TRAVAN or QIC tape, running two or three retention passes will usually return the tape to readable status. The reten command does nothing if issued to other types of tape drives such as DAT , AIT , DLT, or LTO.

tell
Syntax: tapectl tell

The tell command reports the current block location on the tape. Tapes write data in blocks. Using tell can make it easier to locate a specific file or backup set on the tape.

seek
Syntax: tapectl seek 3245

The seek command tells the drive to position the tape to the block specified by the numeric argument provided.

setblk
Syntax: tapectl setblk 0

The setblk, or set block command sets the physical block size that data is separated into when it is written to the tape surface. For SCSI and Fibre-Channel drives, both variable and fixed block sizes are supported. For ATAPI based drives (usually found in Firewire and USB versions of a drive), only fixed block operation is supported. For most SCSI drives, variable block mode is the most efficient operating mode (setblk 0).

alert
Syntax: tapectl alert

The alert command returns the Tape Alert™ status from a compatible tape drive. The Tape Alert status can provide very specific information concerning the health of your tape drive and your media.

unload
Syntax: tapectl unload

The unload command is a synonym for rewoff

wfm
Syntax: tapectl wfm

The wfm command writes a filemark at the current head location on the tape media. By default, when you use the tapewrite tool to write data onto the tape, a filemark is automatically generated when you complete the write process and device is closed.

"tapectl" is a trademark of TOLIS Group, Inc.

Others in this Category
document How do I use the 'tapecopy' command to copy a tape?
document How do I use the 'taperead' command?
document SCSI Compatibility Issues Under Mac OS X
document OS X Standard I/O Streams
document How do I write to a tape with the 'tapewrite' command?
» More Articles



RSS
Powered by KnowledgebasePublisher
Page Load Time: 0.034607 seconds / 34.607 milliseconds.
Page File Size: 32601 bytes.