Jan 052015

I’ve been experiencing problems with Dell running Centos 6 and Bacula 5.2, hooked up to Quantum Scalar i40 tape library with two LTO5 drives. Server has two HBAs, first used with server disks (PERC-310mini) and second LSI SAS2008 with external SAS port connected to tape library. More info about this setup in this post.

Problem: basically, after each server reboot autochanger device was missing.

After spending endless hours I end up with some workaround. Its not ideal, well to be honest its a dirty hack so if there is a better way of doing I would very much appreciate you dropping a quick comment!

So if you can’t find tape library changer under centos 6 with a quantum scalar i40 then read on…

But first, random picture from my library, it seems like she’s showing to her pal a funny cat picture on her phone.


Background: Autochanger is being managed via one of the drives, this is called Control Path and being set once via autochanger web interface.

From time to time Quantum Scalar i40 autochanger is not getting detected after server reboot. In order to detect it we need to rescan SCSI bus.

Lets say tape drives are on controller 0, channel 0, with ID 0 LUN 0 and ID 1 LUN 0

[email protected]:~ # lsscsi
[0:0:0:0]    tape    HP       Ultrium 5-SCSI   Z64Z  /dev/st0 
[0:0:1:0]    tape    HP       Ultrium 5-SCSI   Z64Z  /dev/st1 
[1:0:32:0]   enclosu DP       BP12G+           1.00  -       
[1:2:0:0]    disk    DELL     PERC H310        2.12  /dev/sda

in which case we can find controller (aka Control Path) connected on LUN 1 of one of the drives – but it is not being detected by OS for some reason! This is a bit that puzzles me. I suspect that this is due to my Host Bus Adapters getting different IDs after reboot, i.e. sometimes PERC gets detected as 0 and sometimes SAS2008 gets it – quoted example shows the later case.

[email protected]:~ # echo 0 0 1 >  /sys/class/scsi_host/host0/scan
[email protected]:~ # echo 0 1 1 >  /sys/class/scsi_host/host0/scan

[email protected]:~ # lsscsi
[0:0:0:0]    tape    HP       Ultrium 5-SCSI   Z64Z  /dev/st0 
[0:0:1:0]    tape    HP       Ultrium 5-SCSI   Z64Z  /dev/st1 
[0:0:1:1]    mediumx QUANTUM  Scalar i40-i80   153G  /dev/sch0
[1:0:32:0]   enclosu DP       BP12G+           1.00  -       
[1:2:0:0]    disk    DELL     PERC H310        2.12  /dev/sda 

Solution: aka dirty hack, upon reboot we grep logs to check SCSI id of tapes and use that to rescan bus on tape drive SCSI id but changing LUN +1. Can be used to write init script that starts just before bacula-sd starts, I guess…

This one liner will generate commands we need:

grep tape /var/log/messages*|cut -d" " -f7|awk -F: '{print "echo "$2" "$3" "1 " > /sys/class/scsi_host/host"$1"/scan"}'

double check those lines and and run them.

Restart bacula storage daemon

service bacula-sd restart

Useful commands:

cat /proc/scsi/sg/device_hdr /proc/scsi/sg/devices
host	chan	id	lun	type	opens	qdepth	busy	online
0	0	0	0	1	1	254	0	1
0	0	1	0	1	1	254	0	1
1	0	32	0	13	1	256	0	1
1	2	0	0	0	1	256	0	1
0	0	1	1	8	1	254	1	1

[email protected]:~ # sg_scan
/dev/sg0: scsi0 channel=0 id=32 lun=0
/dev/sg1: scsi0 channel=2 id=0 lun=0
/dev/sg2: scsi1 channel=0 id=5 lun=0
/dev/sg3: scsi1 channel=0 id=7 lun=0
/dev/sg4: scsi1 channel=0 id=7 lun=1

tapeinfo -f /dev/sg2

How do I rescan the SCSI bus to add or remove a SCSI device without rebooting the computer


I know more about SCSI now that I ever wished to know.