Tape rewinds even when told not to
Hi all. I am playing around with rewinding on tapes. Our tape drive is 0 under /dev/rmt. So, I am using /dev/rmt/0n to backup two files at two different intervals on the same tape. But the last file seems to rewrite the whole content of the tape, even when I use the no-rewind option. Could anyone tell me what is wrong ?
Here's an example:
$
$ touch fileone
$ touch filetwo
$
$ mt -f /dev/rmt/0 status
HP Ultrium LTO 3 tape drive:
sense key(0x0)= No Additional Senseresidual= 0retries= 0
file no= 0block no= 0
$
$ mt -f /dev/rmt/0 rewind
$
$ tar cvf /dev/rmt/0n fileone
a fileone 0 tape blocks
$
$ tar cvf /dev/rmt/0n filetwo
a filetwo 0 tape blocks
$
$ mt -f /dev/rmt/0 rewind
$
$ tar tvf /dev/rmt/0n
-rw-r--r--0/10 Oct 4 14:51 2006 fileone
$ tar tvf /dev/rmt/0
-rw-r--r--0/10 Oct 4 14:51 2006 filetwo
How is that possible ? Why is fileone on 0n and filetwo on 0 ? Any help would be extremely appreciated.
[1065 byte] By [
JAMartinez] at [2007-11-26 10:34:48]

# 1
> Hi all. I am playing around with rewinding on tapes.
> Our tape drive is 0 under /dev/rmt. So, I am using
> /dev/rmt/0n to backup two files at two different
> intervals on the same tape. But the last file seems
> to rewrite the whole content of the tape, even when I
> use the no-rewind option. Could anyone tell me what
> is wrong ?
[snip]
> $ mt -f /dev/rmt/0 rewind
> $ tar tvf /dev/rmt/0n
> -rw-r--r--0/10 Oct 4 14:51 2006 fileone
> $ tar tvf /dev/rmt/0
> -rw-r--r--0/10 Oct 4 14:51 2006 filetwo
So by reading the tape, you see both files. How can you say that the last file has rewritten the whole content? They're both still there....
I'm afraid I don't see what your problem is.
> How is that possible ? Why is fileone on 0n and
> filetwo on 0 ?
0 and 0n are the same tape drive. The only difference is whether or not the tape rewinds after the device is closed. It rewinds for 0, not for 0n.
Can you write down what you expected to see instead?
--
Darren
# 2
Hi Darren, sorry for the confusions, it just that it impressed me when I see both files when using 0 and 0n respectly.
Here's a more clear example:
$
$ touch fileone
$ touch filetwo
$
$ mt -f /dev/rmt/0n status
HP Ultrium LTO 3 tape drive:
sense key(0x0)= No Additional Senseresidual= 0retries= 0
file no= 0block no= 0
$
$ mt -f /dev/rmt/0n rewind
$
$ tar cvf /dev/rmt/0n fileone
a fileone 0 tape blocks
$ tar cvf /dev/rmt/0n filetwo
a filetwo 0 tape blocks
$
$ mt -f /dev/rmt/0n rewind
$
$ tar tvf /dev/rmt/0n
-rw-r--r--0/10 Oct 4 18:33 2006 fileone
$
I am expecting tar to show me the whole content of the tape, on which case I expect to see both files listed, fileone and filetwo. Let me know If I explained myself well this time. And thank you for taking the time to look at my question.
# 3
> I am expecting tar to show me the whole content of
> the tape, on which case I expect to see both files
> listed, fileone and filetwo. Let me know If I
> explained myself well this time. And thank you for
> taking the time to look at my question.
No, that's not how tar works.
Tar reads one "file" at a time (be it on disk or on tape). That single tarfile may contain multiple files. (using "file" in two contexts here).
When you run 'tar c ...' a second time, you are creating a second tar file on tape. You therefore have to either run 'tar t.. ' twice to read the contents, or go to the file you want before running tar.
What you want is the equivalent of 'tar r...' or 'tar u...'. However those functions are traditionally not reliable. Instead it would be common to just write a new file on tape and keep track of which file you are interested in.
--
Darren
# 4
Thanks Darren. Please, bear with me on this.
$
$ touch fileone
$ touch filetwo
$
$ mt -f /dev/rmt/0 rewind
$
$ tar cvf /dev/rmt/0n fileone
a fileone 0 tape blocks
$
$ tar cvf /dev/rmt/0n filetwo
a filetwo 0 tape blocks
$
$ mt -f /dev/rmt/0 rewind
$
$ tar tvf /dev/rmt/0
-rw-r--r--0/10 Oct 6 10:24 2006 fileone
$
$ tar tvf /dev/rmt/0
-rw-r--r--0/10 Oct 6 10:24 2006 fileone
$
Why I dont get the second file like you said when I run again tar t... ?
# 5
> Thanks Darren. Please, bear with me on this.
> $ mt -f /dev/rmt/0 rewind
> $
> $ tar tvf /dev/rmt/0
> -rw-r--r--0/10 Oct 6 10:24 2006 fileone
> $
> $ tar tvf /dev/rmt/0
> -rw-r--r--0/10 Oct 6 10:24 2006 fileone
> $
>
> Why I dont get the second file like you said when I
> run again tar t... ?
Because in the first tar you use the device '0'. Since there's no 'n' on the end, it rewinds the tape when you finish.So the second tar is also starting from the beginning of the tape.
You have to use the '0n' device to leave the tape in position after the tar closes the device.
Or do an explicit:
mt -f 0n rewind
mt -f 0n fsf
tar tf 0n
It's usually good practice to *always* use the 'n' device and then just explicitly rewind it when you're ready.
--
Darren
# 6
Duuhh.. dumb me, now I get it. Thank you very much Darren, you're been too helpfull.
One last question though, let me see if I get this straight, everytime I use tar c, it creates a new tar file, reason why when I use tar t it only shows me only file (obviously I'm tar'ing one file at a time) and the whole content of the tape (the two files) because they are different tar files, therefore I need to request again a list (tar t) to get the other tar archive shown.. I am right ?
Thanks!
# 7
Martinez,Darren has given you a good basic knowledge of tar.Why don't you tar both the files together and then go ahead with the tar tvf command.You will be satisfied 100%sunish
# 8
> One last question though, let me see if I get this
> straight, everytime I use tar c, it creates a new tar
> file.
Yes.
> reason why when I use tar t it only shows me
> only file (obviously I'm tar'ing one file at a time)
> and the whole content of the tape (the two files)
> because they are different tar files, therefore I
> need to request again a list (tar t) to get the other
> tar archive shown.. I am right ?
Yes, I suppose so.
A tape drive cannot be used like a disk which has fast access to any point and the ability to delete arbitrary data. So they are almost never used for running a filesystem. They do that very poorly.
Tape drives are best when you can batch (and keep track of) lots of data at one time. Creating separate tar files for one file at a time is very difficult to track (but not impossible).
Perhaps you'd need to devise your own inventory so that you knew what file and version was on each different tape file.
--
Darren