1753445 Members
5308 Online
108794 Solutions
New Discussion юеВ

Re: erase the tape

 
hnlixm
Advisor

Re: erase the tape

maybe it's a no-rewind device,but how can i make sure
Steven Schweda
Honored Contributor

Re: erase the tape

> maybe it's a no-rewind device,

Maybe _what_ is? "/dev/rmt/0m"? The name
with no "n" in it? Guess again.

> but how can i make sure

One way would be to use "tar" twice, and then
see if you got one or two archives on the
tape. If you get two, then it's not
rewinding between the "tar" jobs.
hnlixm
Advisor

Re: erase the tape

yes ,with no 'n' ,it is "/dev/rmt/0m"

i get a job ,so it must be a rewind tape.

but how can i see other files? i can only see the lastest file after i run "tar"
OldSchool
Honored Contributor

Re: erase the tape

hnlixm> i run

mt -f /dev/rmt/0m rewind
--- which rewound the tape
(1)
tar cvf /dev/rmt/0m 200908.tar.Z
a 200908.tar.Z 2280933 blocks
--- which wrote 200908.tar.Z to tape, and then REWOUND it

(2)
tar tvf /dev/rmt/0m
rw-rw-rw- 1001/107 1167837679 Aug 21 17:37 2009 200908.tar.Z
--- which read the tape contents, and then REWOUND it, which impacts the following, as you are now at the beginning of the tape

(3)
tar cvf /dev/rmt/0m 1.log
a 1.log 170 blocks
--- which wrote 1.log to the tape and then REWOUND it

(4)
tar tvf /dev/rmt/0m
rw-rw-rw- 1001/107 86588 Aug 24 17:57 2009 1.log
tar -tvf /dev/rmt/0m 200908.tar.Z
rw-rw-rw- 1001/107 86588 Aug 24 17:57 2009 1.log
--- yep, 1.log is the only thing on the tape. Remember, it rewound to the begining
--- when step (2) finished, so step (3) overwrote what was on it. you have to skip to the end of tape before (3), or use a non-rewind device, as in /dev/rmt/0mn, in step (2).

Using tar to append archives to a tape can be deadly, for just the reasons illustrated. I highly recommend that you DON'T use it this way. If you insist on doing so, read the man pages for "mt" and "tar" carefully. For what it's worth, I wouldn't trust the "append" option of tar as far as I could throw the server.

Steven Schweda
Honored Contributor

Re: erase the tape

> [...] For what it's worth, I wouldn't trust
> the "append" option of tar as far as I
> could throw the server.

You mean this one?

"man tar":

[...]
r

Add the named file to the end of the archive. The same blocking factor used to create
the archive must be used to append to it. This option cannot be used if the archive is a tape.
[...]

The "cannot be used if" part would seem to
limit the threat.

> [...] which impacts the following, [...]

Does it leave a crater?
OldSchool
Honored Contributor

Re: erase the tape

that's the part, I was afraid the OP would stop at:


Add the named file to the end of the archive. The same blocking factor used to create


and never read:

This option cannot be used if the archive is a tape


as to the crater, sure it does. just about the size of the overwritten file :)

hnlixm
Advisor

Re: erase the tape

[...]--- when step (2) finished, so step (3) overwrote what was on it. you have to skip to the end of tape before
>how can i skip to the end of tape? i run "
mt -f /dev/rmt/0m eof " ?

[...] (3), or use a non-rewind device, as in /dev/rmt/0mn, in step (2).


> i run "
# tar -cvf /dev/rmt/0mn 1.txt
a 1.txt 1 blocks
# tar -cvf /dev/rmt/0mn 1.log
a 1.log 170 blocks
# tar -tvf /dev/rmt/0m
rw-rw-rw- 0/3 6 Aug 21 17:32 2009 1.txt
# tar -tvf /dev/rmt/0mn
rw-rw-rw- 1001/107 86547 Aug 25 17:32 2009 1.log
"

so the tape may wind forward when i run "tar -cvf /dev/rmt/0mn"

how can i see all the files in one command instead of two ?




Steven Schweda
Honored Contributor

Re: erase the tape

> how can i see all the files in one command
> instead of two ?

One way would be to write the files to the
tape in one command instead of two.

A "tar -c" command writes one "tar" archive.
A "tar -t" (or "-x") command reads one "tar"
archive. A "tar" archive can contain more
than one file. For example:

tar -cvf /dev/rmt/0mn 1.log 1.txt

"man tar" might be useful.
Dennis Handly
Acclaimed Contributor

Re: erase the tape

>mt -f /dev/rmt/0m eof?

This will fail without a no-rewind device.

>how can I see all the files in one command instead of two?

You can't. Don't do this if you want to protect the data that's on your tape!
Note OldSchool's warning.
hnlixm
Advisor

Re: erase the tape

>[...]A "tar -t" (or "-x") command reads one "tar"


i run "man tar":
"-t List the names of all the files in the archive."

it should not read only a file