1827435 Members
4728 Online
109965 Solutions
New Discussion

Tape device drives

 
SOLVED
Go to solution
Chern Jian Leaw
Regular Advisor

Tape device drives

How do I check for the availability of a tape device drive? i.e I would like to see if e.g /dev/rmt0 is occupied by a tape.
I've used gtar and also tar for archiving and restoration.
4 REPLIES 4
David Burgess
Esteemed Contributor
Solution

Re: Tape device drives

Hi,

If you've got a tape in the drive you get this :-

root:raver:
/ > mt -t /dev/rmt/0m rewind

root:raver:
/ > echo $?
0

If the tape is in use you get this :-

root:raver:
/ > mt -t /dev/rmt/0m rewind
/dev/rmt/0m: Device busy

root:raver:
/ > echo $?
1

If there is not tape in the frive you get this :-

root:raver:
/ > mt -t /dev/rmt/0m rewind
/dev/rmt/0m: No such device or address

root:raver:
/ > echo $?
1

Therefore you can write a script to check the exit code.

A=$?
if [[ $A = 0 ]]
then
echo "Tape in drive"
else
echo "No tape in drive"
fi

HTH

Dave.

James Murtagh
Honored Contributor

Re: Tape device drives

Use the mt command to do this. ie

mt -t /dev/rmt/0m status

Drive: HP C1537A
Format:
Status: [0]
File: 0
Block: 0


mt -t /dev/rmt/1m status

no tape loaded
John Carr_2
Honored Contributor

Re: Tape device drives

Hi

do command

mt rew

this will complain if no tape drive or no tape in drive

cheers
John.
John Carr_2
Honored Contributor

Re: Tape device drives

Hi

also check man page for mt

man mt

there are lots of thiings you can do to manipulate the tape.

cheers
John.