On unix systems the mtx utility is useful for media movement within a tape library. This article describes some of the most common commands for tape movement within a library. The mtx utility takes commands of the form
mtx -f <sg device> <command>
mtx -f <sg device> status For example: # mtx -f /dev/sg6 status Storage Changer /dev/sg6:4 Drives, 121 Slots ( 1 Import/Export ) Data Transfer Element 0:Empty Data Transfer Element 1:Empty Data Transfer Element 2:Empty Data Transfer Element 3:Empty Storage Element 1:Full :VolumeTag=SDE121S Storage Element 2:Full :VolumeTag=SDE122S Storage Element 3:Full :VolumeTag=SDE123S Storage Element 4:Full :VolumeTag=SDE124S Storage Element 5:Full :VolumeTag=SDE125S Storage Element 6:Full :VolumeTag=SDE126S Storage Element 7:Empty Storage Element 8:Empty .... Storage Element 120:Empty Storage Element 121 IMPORT/EXPORT:Full :VolumeTag=SDE120S
Drive numbers are specified starting from zero. i.e Drive 0, Drive 1 etc. While storage element addresses are specified starting from 1. i.e Slot 1, Slot 2 etc
mtx -f <sg device> first <drive number> The above command loads the tape drive specified with a tape cartridge from the first storage slot. If driver number is not specified, then the first drive (drive 0) is used Examples: # mtx -f /dev/sg6 first Loading media from Storage Element 1 into drive 0...done #mtx -f /dev/sg6 first 3 Loading media from Storage Element 1 into drive 3...done
mtx -f <sg device> unload The above command unloads the first tape drive For example: # mtx -f /dev/sg6 unload Unloading drive 0 into Storage Element 1...done When unloading a tape drive, the tape drive number can also be specified using the command below mtx -f <sg device> unload <slot number> <drive number> For example: mtx -f /dev/sg6 unload 1 3 Unloading drive 3 into Storage Element 1...done
It is possible to load the cartridges in a sequential manner, for example load the first cartridge, unload the first cartridge, load the second cartridge etc. This is possible using the 'next' command
As an example: # mtx -f /dev/sg6 first Loading media from Storage Element 1 into drive 0...done # mtx -f /dev/sg6 next Unloading drive 0 into Storage Element 1...done Loading media from Storage Element 2 into drive 0...done Similar to the first command the next command also takes a drive number. Also the next slot that would be use will depend on the slot from which the current tape was loaded. For example consider the following Data Transfer Element 2:Full (Storage Element 4 Loaded):VolumeTag = SDE123S Drive 2 was loaded with a tape from storage slot 4 The following command will load drive 2 with tape from storage slot 5 # mtx -f /dev/sg6 next 2 Unloading drive 2 into Storage Element 4...done Loading media from Storage Element 5 into drive 2...done
It is possible to specify the tape drive to use in a multi-tape drive library system and also the specific storage slot to use.
For example: # mtx -f /dev/sg6 load 4 3 Loading media from Storage Element 4 into drive 3...done # mtx -f /dev/sg6 unload 10 3 Unloading drive 3 into Storage Element 10...done
mtx -f <sg device> transfer <source slot> <destination slot> Examples: # mtx -f /dev/sg6 transfer 2 121 # mtx -f /dev/sg6 status ... Storage Element 2:Empty ... Storage Element 121 IMPORT/EXPORT:Full :VolumeTag=SDE121S
The above command also exports a tape from the library, while the opposite would have imported a tape into the library
Read the man page of mtx for all commands and options supported by mtx. Some take libraries will require that you eject a tape from the drive before media movement is possible, also some tape libraries require that you position the picker to an element first before media movement is possible etc.