mtx-changer script catches me

NOTE: this problem may not be a problem. After rebooting the system while having the tape library powered up, the problem went away. This may or may not be coincident.

Note to self: mtx-changer needs more customization than I thought.

Today showed great progress in completing the integration of my tape library into my Bacula system. I have been writing the testing and configuration of supporting tools. I had moved onto a new article outlining the integration phase (still under construction). That’s when I found a pretty big block in the mtx-changer script. It is this function:

#
# The purpose of this function to wait a maximum
#   time for the drive. It will
#   return as soon as the drive is ready, or after
#   waiting a maximum of 300 seconds.
# Note, this is very system dependent, so if you are
#   not running on Linux, you will probably need to
#   re-write it, or at least change the grep target.
#   We've attempted to get the appropriate OS grep targets
#   in the code at the top of this script.
#
wait_for_drive() {
  i=0
  while [ $i -le 300 ]; do  # Wait max 300 seconds
    if mt -f $1 status 2>&1 | grep "${ready}" >/dev/null 2>&1; then
      break
    fi
    debug "Device $1 - not ready, retrying..."
    sleep 1
    i=`expr $i + 1`
  done
}

The problem is, when bacula-sd is running, you cannot get the status of the tape drive. At least with my system. It is *always* busy. This, this function always times out.

For example:

$ sudo mtx -f /dev/nsa1 status
cannot open SCSI device '/dev/nsa1' - Device busy

My solution, yet to be tested:

wait_for_drive() {
  debug "waiting for Device $1"
  sleep 25
}

We’ll see.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Leave a Comment

Scroll to Top