LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Simple tape drive questions (https://www.linuxquestions.org/questions/linux-hardware-18/simple-tape-drive-questions-514425/)

helpmhost 12-28-2006 05:05 PM

Simple tape drive questions
 
Hi,

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:
http://nic.phys.ethz.ch/readme/80
http://baheyeldin.com/linux/using-ta...e-network.html
Oreilly Essential System Administration - 3rd Edition

Thanks.

stress_junkie 12-28-2006 09:51 PM

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.
Code:

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.
http://www.computerhope.com/unix/umt.htm
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.
Code:

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.
Code:

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. :)

helpmhost 12-29-2006 12:54 AM

Thanks for the reply. It was very helpful and answered all my questions.


All times are GMT -5. The time now is 11:09 AM.