CentOS 7.x mt

From Notes_Wiki
Revision as of 09:09, 25 August 2022 by Saurabh (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Home > CentOS > CentOS 7.x > Command line tools and utilities > CentOS 7.x mt


It is possible to use magnetic tape drive directly from Linux command line using 'mt' command. There is similar st command for SCSI tape drives.

Erase tape

To erase tape and make it completely blank for new use:

mt -f /dev/st0 erase


Rewind tape

To rewind tape use:

mt -f /dev/st0 rewind


Add data to tape

In quick experiments it looked like storing multiple objects and using tape forward, backward, etc. may not work. In this case to store multiple objects we can use Linux tar command to convert folder/sub-folders and files to a single archive. However, unless required avoid compression so that selectively files can be listed, extracted, etc. without requiring decompression of entire archive.

To add directory to tape after appropriate erase, rewind use:

tar -cf /dev/st0 /etc

For compression add 'z' or 'j' to tar options appropriately.


List contents of tape

To list contents use:

tar -tf /dev/st0

This might require rewind to again point to start of tape.


Extract contents

To extract contents use:

tar -xf /dev/st0 [<file-or-folder-to-extract>]

This might require rewind to again point to start of tape.


Check tape status

To check tape status use:

mt -f /dev/st0  status


Eject or remove tape

To eject or remote tape use:

mt -f /dev/st0  offline


Move record-wise

It is possible to use entire tape for a single tar archive as suggested before. However, for multiple data store / retrieval there is option to move forward/backward in records.

Go to previous record

To go to previous record use:

mt -f /dev/nst0  bsfm 1

Note use of nst0 instead of st0

Go to next record

To go to next record use:

mt -f /dev/nst0  fsf 1

Note use of nst0 instead of st0


Refer:


Home > CentOS > CentOS 7.x > Command line tools and utilities > CentOS 7.x mt