System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

fbackup - how to change a tape by using chgvol?

 
SOLVED
Go to solution
Highlighted
Trusted Contributor

Re: fbackup - how to change a tape by using chgvol?

Hi Kehad,

good progress! I think this may be to do with the "fun" I also had between how different devices behave. An autoloader (such as yours I believe) can easily get confused if you try and use commands that are for "random" access loaders (i.e. proper libraries). In fact, `mc` would not work at all on devices that only understand "sequential" movement - and I think this is what you are seeing. Although it would be great to be able to use `mc` as it is far more flexible, it's making it more difficult!

That is why/how I ended up with the script I was using - I think I actually found it, or the basis for it at least, in a very old forum posting. It gets round the issue with "autoloaders" versus "libraries" by being very basic.

With a "sequential" drive, a `mt offline` will simply unload the current tape and load the next one. So the chgvol script simply needs to do a `mt offline` and then wait until the next time is ready...

Hope that helps.
Graham.
Highlighted
Frequent Advisor

Re: fbackup - how to change a tape by using chgvol?

hi graham,

thanks for your reply.

i so not fully understand you script. can you please give me a brief description.

i cannot see the command which will create an archive on tape.

this is your script content:

#!/usr/local/bin/bash

set -xv

sleep 60

count=1

mt offl
sleep 10

rewindme=1

while [ ${rewindme} -ne 0 ] ;
do

sleep 60
mt rew
rewindme=$?

let count=count+1
if [ ${count} = 11 ];
then
echo Something has gone horribly wrong...
exit 1
fi

done

sleep 30
exit 0


thank you in advance!
Trusted Contributor
Solution

Re: fbackup - how to change a tape by using chgvol?

Hi Kehad,

you are correct that there are no lines in this script for doing the backup - this is ONLY the chgvol scipt, NOT the script that does the backup.

So in essence, you would do the backup the same way as you are currently - i.e. through SAM - but instead of your chgvol script (which is now being executed, but failing), run this replacement chgvol script instead.

This script simply changes the tape using "mt offline" which works well for sequential auto-loaders, instead of using "mc" which can confuse things...

Hope that makes sense - if not, let me know.
Highlighted
Frequent Advisor

Re: fbackup - how to change a tape by using chgvol?

thanks man,

i understand now. i will implement and revert back to you.
Highlighted
Frequent Advisor

Re: fbackup - how to change a tape by using chgvol?

Hi Graham,

i implemented you script but its only taking the tape offline and not unloading the tape currently in the drive and not loading a new tape in the slots. Below is the output when i execute the script:

_____________________________________________
root@Rogue:/var/adm/fbackupfiles # ./chgvol

sleep 60
+ sleep 60

count=1
+ count=1

mt offl
+ mt offl
sleep 10
+ sleep 10

rewindme=1
+ rewindme=1

while [ ${rewindme} -ne 0 ] ;
do

sleep 60
mt rew
rewindme=$?

let count=count+1
if [ ${count} = 11 ];
then
echo Something has gone horribly wrong...
exit 1
fi

done
+ [ 1 -ne 0 ]
+ sleep 60
+ mt rew
/dev/rmt/0mnb: No such device or address
+ rewindme=1
+ let count=count+1
+ [ 2 = 11 ]
+ [ 1 -ne 0 ]
+ sleep 60
+ mt rew
/dev/rmt/0mnb: No such device or address
+ rewindme=1
+ let count=count+1
+ [ 3 = 11 ]
+ [ 1 -ne 0 ]
+ sleep 60
+ mt rew
/dev/rmt/0mnb: No such device or address
+ rewindme=1
+ let count=count+1
+ [ 4 = 11 ]
+ [ 1 -ne 0 ]
+ sleep 60
+ mt rew
/dev/rmt/0mnb: No such device or address
+ rewindme=1
+ let count=count+1
+ [ 5 = 11 ]
+ [ 1 -ne 0 ]
+ sleep 60
+ mt rew
/dev/rmt/0mnb: No such device or address
+ rewindme=1
+ let count=count+1
+ [ 6 = 11 ]
+ [ 1 -ne 0 ]
+ sleep 60
+ mt rew
/dev/rmt/0mnb: No such device or address
+ rewindme=1
+ let count=count+1
+ [ 7 = 11 ]
+ [ 1 -ne 0 ]
+ sleep 60
+ mt rew
/dev/rmt/0mnb: No such device or address
+ rewindme=1
+ let count=count+1
+ [ 8 = 11 ]
+ [ 1 -ne 0 ]
+ sleep 60
+ mt rew
/dev/rmt/0mnb: No such device or address
+ rewindme=1
+ let count=count+1
+ [ 9 = 11 ]
+ [ 1 -ne 0 ]
+ sleep 60
+ mt rew
/dev/rmt/0mnb: No such device or address
+ rewindme=1
+ let count=count+1
+ [ 10 = 11 ]
+ [ 1 -ne 0 ]
+ sleep 60
+ mt rew
/dev/rmt/0mnb: No such device or address
+ rewindme=1
+ let count=count+1
+ [ 11 = 11 ]
+ echo Something has gone horribly wrong...
Something has gone horribly wrong...
+ exit 1
root@Rogue:/var/adm/fbackupfiles #
_____________________________________________

what should i do next in order for this to work as intented?
Highlighted
Frequent Advisor

Re: fbackup - how to change a tape by using chgvol?

and i do have a tape device with device files as follows:

root@Rogue:/var/adm/fbackupfiles # ioscan -fnC tape
Class I H/W Path Driver S/W State H/W Type Description
=====================================================================
tape 0 0/0/2/0.3.0 stape CLAIMED DEVICE HP C1537A
/dev/rmt/0m /dev/rmt/0mnb /dev/rmt/c2t3d0BESTn /dev/rmt/c2t3d0DDSb
/dev/rmt/0mb /dev/rmt/c2t3d0BEST /dev/rmt/c2t3d0BESTnb /dev/rmt/c2t3d0DDSn
/dev/rmt/0mn /dev/rmt/c2t3d0BESTb /dev/rmt/c2t3d0DDS /dev/rmt/c2t3d0DDSnb
root@Rogue:/var/adm/fbackupfiles #
Highlighted

Re: fbackup - how to change a tape by using chgvol?

>what should i do next in order for this to work as intended?
/dev/rmt/0mnb: No such device or address

You need to change your script to add "-f your-tape-device" to every one of your mt commands.

/dev/rmt/0mnb is listed but it isn't working??
Highlighted
Honored Contributor

Re: fbackup - how to change a tape by using chgvol?

I think the only way you can fix this is to test your chgvol separately from fbackup. When you run the SAM backup, you cannot see anything concerning your chgvol script. I would also take out the 60 second wait and instead, request a status from the tape drive using mt/status, then loop around with a 5 second wait until the tape reports BOT, something like this:

#!/usr/bin/sh
# fbackup has started rewinding the tape
# chgvol (this script) has been called
# Must define the tape being used
# exit with error after waiting 2 minutes

MYTAPE=/dev/rmt/0m
STATUS=$(mt -f $MYTAPE status)
echo "$STATUS"
COUNT=0
while [ $(echo $STATUS | grep -c BOT) -eq 0 ]
do
COUNT=$((COUNT+1))
[ $COUNT -gt 20 ] && exit 1 ## too long
sleep 5
STATUS=$(mt -f $MYTAPE status)
done
# Now change the tape
...mc commands...

Run this script with the -x option as in:

sh -x chgvol

This will trace the chgvol script. Be sure you always start your scripts with #!/usr/bin/sh

Once this script is working by itself, now you can try it with fbackup. Be sure your -c configfile has DDS parameters for efficiency and speed. This is will work quite well with all DDS tape drives:

blocksperrecord 4096
records 64
checkpointfreq 4096
readerprocesses 6
maxretries 5
retrylimit 5000000
maxvoluses 200
filesperfsm 2000



Bill Hassell, sysadmin
Highlighted
Trusted Contributor

Re: fbackup - how to change a tape by using chgvol?

Hi Kehad,

Firstly, I think you did the right thing running the chgvol script independently of the backup - to check it is working first...

It looks to me like the "mt offline" is working, but as you say, the library/autoloader is not then automatically loading the next tape.

Do you know if you can configure the autoloader so it is in "sequential" mode? There are (normally) 3 modes an autoloader/library can be in - "sequential", "auto" and "random". I suspect you NEED "sequential". Hopefully you might be able to configure this on the front of the autoloader...

In anycase, even separate to the chgvol script, if you load a tape in the drive and then simply do a "mt offline" at the command line, you should see the drive unload and then automatically load the next tape. Once this happens, you can be sure the chgvol script will work also... :)

Silly question - has the loader been rebooted since you were trying the "mc" command some time ago? I found that if the autoloader was set to "auto" mode, once an "mc" command was used, the autoloader needing rebooting to then get "mt offline" to work! If you haven't rebooted the autoloader, it might be worth doing. That's why its better to force the device into "sequential" mode...

Let us know how you get on...good luck!

Highlighted
Frequent Advisor

Re: fbackup - how to change a tape by using chgvol?

the autoloader (A3716A) can be operated in either stacker or random mode only.

the mode is initially detemined by whathappens after you insert a magazine:

- if the host sends a command (move medium) to move a cartridge from the magazine to the drive, the autoloader goes into random mode.

- if you select a cartridge by pressing the Select buttom and then load it by pressing the Load Cartridge button, the autoloader goes into stacker mode.

i changed the script i am currently using (added mc commands to unload current tape and load new tape) which is executed successfully and changing the tape as it should but the confirmation is not being confirmed. after the script is executed it still prompts me to press Y/N to continue. how can i get pass confirmation?

can i add something to the script below to confirm with Y and continue?

my script:
-------------------------------------------
#!/usr/bin/sh

set -xv

sleep 60

count=1

mt -f /dev/rmt/0mn offl
sleep 10

rewindme=1

while [ ${rewindme} -ne 0 ] ;
do

sleep 60
mc -p /dev/rac/c2t3d1 -s D1 -d S1
sleep 60
mc -p /dev/rac/c2t3d1 -s S2 -d D1
rewindme=$?

let count=count+1
if [ ${count} = 11 ];
then
echo Something has gone horribly wrong...
exit 1
fi

done

sleep 30
exit 0
-------------------------------------------