Linux tape backup with mt and tar command - howto
Magnetic tape is a non-volatile storage medium consisting of a magnetic coating on a thin plastic strip. Nearly all recording tape is of this type, whether used for video, audio storage or general purpose digital data storage using a computer.
Linux (and other Unixish system) use mt command to control magnetic tape drive operation. You need to use mt command while working with tape drive. It allows you to reading and writing to tape.
The default tape drive under Linux is /dev/st0 (first SCSI tape device name). You can read more about tape drives naming convention used under Linux here. Following paragraph summaries command you need to use control tape drive for backup/restore purpose.
Rewind tape drive:# mt -f /dev/st0 rewindBackup directory /www and /home with tar command (z - compressed):# tar -czf /dev/st0 /www /homeFind out what block you are at with mt command:# mt -f /dev/st0 tellDisplay list of files on tape drive:# tar -tzf /dev/st0Restore /www directory:# cd /Unload the tape:
# mt -f /dev/st0 rewind
# tar -xzf /dev/st0 www# mt -f /dev/st0 offlineDisplay status information about the tape unit:# mt -f /dev/st0 statusErase the tape:# mt -f /dev/st0 eraseYou can go BACKWARD or FORWARD on tape with mt command itself:
(a) Go to end of data:# mt -f /dev/nst0 eod(b) Goto previous record:# mt -f /dev/nst0 bsfm 1(c) Forward record:# mt -f /dev/nst0 fsf 1 Replace /dev/st0 with your actual tape drive name.
See also:
- Howto - Use tar command through network over ssh session (i.e. writing to tape on a remote Linux server system)
- This small how-to covered all options used in day today life; however, it is highly recommended that you go through man pages of mt and tar command for more options/information.
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- Verify tar command tape backup under Linux or UNIX
- Tape drives naming convention under Linux
- Backup home directories in Linux
- Howto: Use tar command through network over ssh session
- Linux Set the Block Size for a SCSI Tape Device
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: /dev/st0, backup directory, linux mt command, mt_command, scsi tape device, ssh session, tape, tar xzf command, tar_command



October 4th, 2006 at 5:33 am
I am new to Red Hat Linux. I want to know How to copy the whole content of tape drive to thum drive or on system directory
October 6th, 2006 at 3:45 pm
I think you should talk about verifying the backup just after copying files to tape
October 18th, 2006 at 5:32 pm
[...] A. The GNU version of the tar archiving utility has –exclude and -X options. So to exclude abc and xyz file you need to type the command as follows: $ tar -zcvf /tmp/mybackup.tar.gz –exclude=’abc’ –exclude=’xyz’ /home/me [...]
November 26th, 2006 at 3:55 pm
Hi. My name in leon. I thanks you for the support shown for linux. I wish you all the very best and good luck on your work.
April 8th, 2007 at 2:37 pm
Info about how to manage multiple tapes, and what happens when a tape gets full would be handy!
March 5th, 2008 at 10:36 am
whall all should be checked as regular health check of the HP proliant servers having Linux OS platform. what all are the commands to do so?
Regards,
March 10th, 2008 at 4:26 am
Hi am new to linux redhat and require some information in determining if tape drive compression is enabled on the system (ibm ultrium lto3
April 7th, 2008 at 5:10 pm
I have found that on RHL FC8 the mt command doesn’t work. I have had to use the full mount command and it tells me its already mounted. Has the command changed for the free version versus enterprise?
some help on this would be appreciated.
April 23rd, 2008 at 5:43 pm
mt is not mount… if mt doesn’t work then you don’t have the utility installed.
mt stands for magentic tape, it is not short for ‘mount’ like your probably thinking.
June 25th, 2008 (2 weeks ago) at 10:05 pm
Hi Glen,
On my fedora FC8 mt was not installed from the beginning. The suitable package for installation is mt-st (something, mt-st-0.9b-4.fc8.i386)