Showing posts with label rmt. Show all posts
Showing posts with label rmt. Show all posts

Friday, November 10, 2006

The mt command

As I told you earlier, just yesterday I discovered the mt command. I know mv, but mt? Well, I then did a man on it. Mt........what the...........magnetic tape control?! I don't believe this! I can control a tape drive from a PC! I can send commands to it! The last time I did this was with a really old Texas Instruments TI-99/4A. Hmmm......I might explore this........

Anyway, let's get back to mt. Its syntax is mt [ -f tapename ] command [ count ]. Command and count will be explained shortly. The tape selecting option is -f, which selects the raw tape device. I believe /dev/rmt is the /dev folder for this. There are also a number of operands for mt. Here are some of them from http://bama.ua.edu/cgi-bin/man-cgi?mt+1, a online copy of the UNIX man pages:

count - The number of times that the requested operation is to be performed. By default, mt performs command once. Multiple operations of command may be performed by specifying count.

command - Available commands that can be sent to a magnetic tape drive. Only as many characters as are required to uniquely identify a command need be specified.

eof, weof - Write count EOF marks at the current position on the tape.

fsf - Forward space over count EOF marks. The tape is positioned on the first block of the file.

fsr - Forward space count records.

bsf - Back space over count EOF marks. The tape is positioned on the beginning-of-tape side of the EOF mark.

bsr - Back space count records.

nbsf - Back space count files. The tape is positioned on the first block of the file. This is equivalent to count+1. bsf's followed by one fsf.

asf - Absolute space to count file number. This is equivalent to a rewind followed by a fsf count.

(the next section is from http://www.computerhope.com/unix/umt.htm)

If count is specified with any of the following commands, the count is ignored and the command is performed only once.

eom - Space to the end of recorded media on the tape. This is useful for appending files onto previously written tapes.

rewind - Rewind the tape.

offline, rewoffl - Rewind the tape and, if appropriate, take the drive unit off-line by unloading the tape. It cycles through all four tapes.

status - Print status information about the tape unit.

retension - Rewind the cartridge tape completely, then wind it forward to the end of the reel and back to beginning-of-tape to smooth out tape tension.

reserve - Allow the tape drive to remain reserved after closing the device. The drive must then be explicitly released.

release - Re-establish the default behavior of releasing at close.

forcereserve - Break the reservation of the tape drive held by another host and then reserve the tape drive. This command can be executed only with super-user privileges.

erase - Erase the entire tape. Erasing a tape may take a long time depending on the device and/or tape. Refer to the device specific manual for time details.

Good, but a bit complicated and technical, as far as explanations. I guess an example (for those of you with tape drives out there) might be:

mt erase - erase the tape in the drive found at /dev/rmt0.

mt -f $RMT_NR eof 1 - Mark the end of the tape.

Very cool. Again, these are just probable examples of mt.

For more info, you can go to that man page I mentioned earlier. Another good place for learning about tapes and Unix is http://www.washington.edu/computing/unix/tapes.html. Also you can go to http://www.computerhope.com/unix/umt.htm for more info on use and syntax. That link also provides a link to a page on tcopy, a command I will be discussing soon. Enjoy!