Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Hardware
User Name
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?


  Search this Thread
Old 12-28-2006, 05:05 PM   #1
Registered: Oct 2006
Posts: 43

Rep: Reputation: 15
Simple tape drive questions


I am new to using tape drives in linux, and have a couple potentially very dumb questions.

I am using tar to back up various directories to tape. I understand how to do this, and how to move the tape to next file etc...

My first question is how to overwrite data on the tape?

I will use an example for this.

I tar a 100 MB folder onto a tape (using /dev/nst0).
I then tar a 50 MB folder to the same tape (using /dev/st0).
Then next day/week/whenever, I want to re-backup those folders, BUT, the 100MB folder is now 60MB.
Do I need to fully erase the tape before I do this? Or can I just tar the folder over the current one? If yes, how does the tape know where to fast forward to when I ask it to fast forward to the 2nd file? How does this work?

Please assume that the tape is not large enough for me to simply add the directory after the first 2 tar archives.

A second question, after archiving the 2nd folder (the 50MB one) using /dev/st0, does it rewind to the beginning of the tape or the beginning of that file?

Before anyone tells me to use google, I would like to say that I have. I have also looked in several linux books and have not found my answers. So I also ask for any links or book recommendations that have good info/tutorials about tape drives in linux.

For other people who may later view this post, here are the best resources I have found:
Oreilly Essential System Administration - 3rd Edition

Old 12-28-2006, 09:51 PM   #2
Senior Member
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
By default, tar will find the end of tape marker (EOT) before it starts writing to a tape. You need to put an EOT marker at the beginning of the tape before you can use the full capacity of it via tar. I use the mt command to do this.
mt -f /dev/st0 retension
mt -f /dev/st0 erase
The retension function is optional and it can take a long time but it is alwawys a good idea. You don't want the last 10 feet of tape to start sticking together just because the tape has never been run to the physical end. You may need that 10 feet of tape some day.

When using the auto-rewind device socket (/dev/st0) any tape operation will rewind to the physical beginning of the tape when the utility finishes. That includes the tar command or the dd command or whatever else you might use to manipulate data on the tape.

Here is a site explaining the use of the mt command.
I found it using Google. I couldn't resist. To be fair I already knew that I was looking for the parameters of the mt command. Unfortunately the computer that I'm using to write this doesn't have the mt utility installed so there is no mt man page on this computer either.

However if your system has the mt utility installed then there should also be a man page for that utility.
man mt
Note that although the web page above says that the mt erase function fully erases the tape contents I have not found that to be the case. In my experience the mt command just places an EOT marker at the beginning of the tape. Times that I wanted to fully erase the contents of a tape I have used the dd comamnd to dump random bytes to the tape.
dd if=/dev/urandom of=/dev/st0 bs=10240 count=1000000000
That line would write 10 gigabytes to /dev/st0 or it would fill up the tape and error out. In this case having it error out is acceptable and ensures that you have filled up the tape. Note that the bs=10240 is for Travan tapes. A true SCSI tape drive would probably want a bs=32768 parameter in order to be efficient. It isn't critical. You can use a bs=1 if you want. It just uses the hardware buffers less efficently. Happy taping.

Last edited by stress_junkie; 12-29-2006 at 08:03 AM.
Old 12-29-2006, 12:54 AM   #3
Registered: Oct 2006
Posts: 43

Original Poster
Rep: Reputation: 15
Thanks for the reply. It was very helpful and answered all my questions.


tape drive

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a DDS5 tape drive to restore from a DDS3 backup tape. AndrewCAtWayofthebit Linux - Hardware 1 05-14-2006 09:15 AM
Floppy drive interfaced tape drive in Slackware isolationist Linux - Hardware 6 02-13-2006 05:54 AM
Linux on second hard drive. Simple questions pmo10 Linux - Hardware 3 01-16-2005 11:48 PM
Simple Gui Tape Backup + RH 7.2 chosmer Linux - General 0 08-12-2002 12:02 PM
2 questions(Re: backup to scsi tape drive) ascii2k Linux - General 5 07-16-2001 05:47 PM > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 10:35 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration