Tape Scanning in Linux
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > WebserverTalk Community > Data Storage > Tape Scanning in Linux




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Tape Scanning in Linux  
2hawks


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-03-05 10:47 PM

Hi,

Could someone kindly tell me how to scan tapes in Linux.  For example,
if there are multiple cpio archives on one tape, how can I find out how
many are on it?  If I am thinking correctly, cpio will only list
whatever is the first archive it finds.

Is it in the method of addressing the device? st0 and nst0 etc? or is
there a utility or command that can essentially ls the tape in the
drive?

Thanks much,
Robert






[ Post a follow-up to this message ]



    Re: Tape Scanning in Linux  
Steve Cousins


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-03-05 10:47 PM

2hawks wrote:

>Hi,
>
>Could someone kindly tell me how to scan tapes in Linux.  For example,
>if there are multiple cpio archives on one tape, how can I find out how
>many are on it?  If I am thinking correctly, cpio will only list
>whatever is the first archive it finds.
>
>Is it in the method of addressing the device? st0 and nst0 etc? or is
>there a utility or command that can essentially ls the tape in the
>drive?
>
>
I just wrote a script to do something very similar with some old Amanda
tapes I have.  Yours should be much simpler. I've changed it to do what
I think you want:

=======================
#!/bin/sh

# Script to do a cpio inventory of a tape.
#
# Assumes:    1. /dev/tape -> /dev/nst0 or other non-rewinding tape device
#             2. not more than 100 tape files on the tape
#             3. programs: mt, seq, cpio, grep, wc, and bc are in PATH
#             4. mt reports "EOD" after end of last tape file is reached

mt rewind

for FILENUM in `seq 1 100`
do
echo "============================="
echo " Contents of file $FILENUM: "
echo "============================="
cpio -tv < /dev/tape

# Check to see if we are at the end of the tape:
END_TEST=`mt status | grep EOD | wc -l | bc`
if [ "$END_TEST" = "1" ]
then
mt offline
exit
fi
done
=======================

While this isn't the most elegant script, it gets the job done.  It will
give a "Input/Output" error after it gets to the end of the last file
because the status is EOF until the last cpio is done and then it goes
to EOD.  Anyone have a better solution to this?

I'd run this as:

./ti.sh > tape_1.log

to save the inventory to a file.

Good luck,

Steve






[ Post a follow-up to this message ]



    Re: Tape Scanning in Linux  
2hawks


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-08-05 10:58 PM

nice... thanks for that. That solves the cpio end of things for me I
guess.  Now I wonder if that would work the same with tar.... or other
methods of writing to tape.  Trick for me would be to develop a script
that just looked at the tape and did and ls of it... not dependent on
cpio or anything.






[ Post a follow-up to this message ]



    Re: Tape Scanning in Linux  
Steve Cousins


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-08-05 10:58 PM

2hawks wrote:

>nice... thanks for that. That solves the cpio end of things for me I
>guess.  Now I wonder if that would work the same with tar.... or other
>methods of writing to tape.  Trick for me would be to develop a script
>that just looked at the tape and did and ls of it... not dependent on
>cpio or anything.
>

cpio will work with tar too.  To check for what type of file is on the
tape you could try putting something like this in your script:

FILE_TYPE=`dd if=/dev/tape bs=32k count=1 | file -`

and then figure out what to do based on what is in the FILE_TYPE variable.

Have fun.

Steve






[ Post a follow-up to this message ]



    Re: Tape Scanning in Linux  
2hawks


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-08-05 10:58 PM

You are a gentleman and a scholar sir! Thanks for your assistance.
Btw, does anyone know if mt senses the actual block size when you do a
status (mt -f /dev/nst0 status) or is that based on driver defaults?






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:34 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register