[Rear-users] Backing up to tape-drive and OBDR

Dag Wieers dag at wieers.com
Thu Aug 26 15:50:31 CEST 2010


On Thu, 26 Aug 2010, Dag Wieers wrote:

> On Tue, 24 Aug 2010, Gratien D'haese wrote:
>> On 24 Aug 2010, at 15:52, Dag Wieers wrote:
>>> On Mon, 23 Aug 2010, Gratien D'haese wrote:
>>>
>>>> I think the procedure could be the following (#host #channel #id #lun
>>>> should be replaced of course)
>>>>
>>>> 1) power cycle tape drive
>>>> 2) from another shell (Alt+F2)
>>>>  - echo "scsi remove-single-device 1 0 3 0" > /proc/scsi/scsi
>>>>  - modprobe st
>>
>> in mu humble opinion modprobe st is the key for geting the tape device
>> into normal mode again, but yeah I was using (>5 yrs ago) simple DDS4
>> tape drives.
>
> We have tested that (based on either the mkcdrec or Mondo Rescue code). To
> no avail :-/

I can now confirm that by testing on a live system (so without doing any 
intermediate reboots to verify) I can swap between CD-ROM and 
Sequential-Access, and back, using the following procedure:

------
[root at dag-ops rear]# sg_wr_mode -f -p 3eh -c 3e,2,1,0 /dev/sg1
[root at dag-ops rear]# cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
   Vendor: HL-DT-ST Model: DVD-ROM DH10N    Rev: DAE1
   Type:   CD-ROM                           ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
   Vendor: HP       Model: Ultrium 4-SCSI   Rev: U52D
   Type:   Sequential-Access                ANSI SCSI revision: 05
[root at dag-ops rear]# echo "scsi remove-single-device 2 0 0 0" > /proc/scsi/scsi
[root at dag-ops rear]# echo "scsi add-single-device 2 0 0 0" > /proc/scsi/scsi
[root at dag-ops rear]# cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
   Vendor: HL-DT-ST Model: DVD-ROM DH10N    Rev: DAE1
   Type:   CD-ROM                           ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
   Vendor: HP       Model: Ultrium 4-SCSI   Rev: U52D
   Type:   CD-ROM                           ANSI SCSI revision: 05

[root at dag-ops rear]# sg_wr_mode -f -p 3eh -c 3e,2,0,0 /dev/sg1
[root at dag-ops rear]# echo "scsi remove-single-device 2 0 0 0" > /proc/scsi/scsi
[root at dag-ops rear]# cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
   Vendor: HL-DT-ST Model: DVD-ROM DH10N    Rev: DAE1
   Type:   CD-ROM                           ANSI SCSI revision: 05
[root at dag-ops rear]# rmmod st
[root at dag-ops rear]# modprobe st
[root at dag-ops rear]# cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
   Vendor: HL-DT-ST Model: DVD-ROM DH10N    Rev: DAE1
   Type:   CD-ROM                           ANSI SCSI revision: 05
[root at dag-ops rear]# echo "scsi add-single-device 2 0 0 0" > /proc/scsi/scsi
[root at dag-ops rear]# cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
   Vendor: HL-DT-ST Model: DVD-ROM DH10N    Rev: DAE1
   Type:   CD-ROM                           ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
   Vendor: HP       Model: Ultrium 4-SCSI   Rev: U52D
   Type:   Sequential-Access                ANSI SCSI revision: 05
------

As you can see reload st (or even sg) doesn't help. I cannot reload cciss 
on a live system as the disks are in use.

Now, the only problem is to identify the correct Controller/Channel/Id/Lun 
on a given system. I am contemplating to have this, like the "engage scsi",
perform by udev. Hoping we have the required information available there, 
somehow. The only other option I see is parsing the above, or rather 
lsscsi output, which I would hope to prevent.

Here is a script that changes the from and to OBDR mode:
------
#!/bin/bash

### Find first Ultrium device
HCIL="$(lsscsi | awk 'BEGIN {FS=""} / +HP +Ultrium/ { print $2, $4, $6, $8; exit }')"
DEVICE="$(lsscsi | awk '/ +HP +Ultrium/ { print $7; exit }')"
STATE="$(lsscsi | awk '/ +HP +Ultrium/ { print $2; exit }')"

echo "We found the Ultrium tape device $DEVICE in state $STATE."

case "$STATE:$1" in
     (tape:on)
         echo "Performing scsi MODE SELECT."
         sg_wr_mode -f -p 3eh -c 3e,2,1,0 $DEVICE
         echo "scsi remove-single-device $HCIL" >/proc/scsi/scsi
         echo "scsi add-single-device $HCIL" >/proc/scsi/scsi
         ;;
     (cd/dvd:off)
         echo "Performing scsi MODE SELECT."
         sg_wr_mode -f -p 3eh -c 3e,2,0,0 $DEVICE
         echo "scsi remove-single-device $HCIL" >/proc/scsi/scsi
         echo "scsi add-single-device $HCIL" >/proc/scsi/scsi
         ;;
     (*)
         echo "ERROR: Device cannot be manipulated. Probably OBDR already in correct state." >&2
         exit 1
         ;;
esac

STATE="$(lsscsi | awk '/ +HP +Ultrium/ { print $2; exit }')"

echo "The Ultrium tape device $DEVICE is now in state $STATE."
------

Which would produce the following:
------
[root at dag-ops ~]# ./set-obdr.sh on
We found the Ultrium tape device /dev/st0 in state tape.
Performing scsi MODE SELECT.
The Ultrium tape device /dev/st0 is now in state cd/dvd.
[root at dag-ops ~]# ./set-obdr.sh off
We found the Ultrium tape device /dev/scd1 in state cd/dvd.
Performing scsi MODE SELECT.
The Ultrium tape device /dev/scd1 is now in state tape.
[root at dag-ops ~]# ./set-obdr.sh off
We found the Ultrium tape device /dev/st0 in state tape.
ERROR: Device cannot be manipulated. Probably OBDR already in correct state.
------

Hopefully this is useful in the future, even if only to test and provide 
feedback. We are getting closer to a working solution...
-- 
--   dag wieers,  dag at wieers.com,  http://dag.wieers.com/   --
[Any errors in spelling, tact or fact are transmission errors]




More information about the rear-users mailing list