# scsi expert needed: howto init tape drive [SOLVED]

## rsa4046

I have an external SCSI LVD tape drive that I'd like to power on and off as need be. The snag is that if gentoo boots with the tape drive turned off, no dev (st0) is created at boot time. How can I force a rescan of the bus so that the correct device node is created and the drive is usable without rebooting? Drive otherwise works fine. TIA!Last edited by rsa4046 on Tue Aug 09, 2005 12:16 am; edited 2 times in total

----------

## keyson

Hi.

Try the http://www.linux1394.org/scripts/rescan-scsi-bus.sh.

A small shell script that rescans the bus.

EDIT: It's in sg3_utils in portage.

----------

## rsa4046

keyson:

Thanks for tip. I tried these utilities, however it seems the device node must exist for these operations (including rescan-scsi-bus.sh script) to succeed. How would I go about manually creating the correct tape (in this case, /dev/st0) device? Thanks again! rsa4046

----------

## keyson

Jep i see what you mean. I have the same with one of my scanners.

I have to modprobe sg before rescan-scsi-bus then it creates the

dev node. But if i only make a rescan it don't load the sg module

and create the device node.

But what the rescan script do is that it enables the scsi card to

detect my scanner.

If you do a 

```
cat /proc/scsi/scsi
```

before you powered up the tapedrive and

then after power-up and then after rescan.

The script should find it.

Try modprobe st

then rescan and se if it creates the st0.

EDIT: When you have powered off the tapedrive you may 'rescan-scsi-bus.sh -r' to remove the

device from the scsi bus.

----------

## rsa4046

keyson: 

I have sg and scsi tape support as part of kernel, not as modules. (Q: Can I boot my scsi HD without generic scsi support?) Would it be better to have sg and st as modules, and thus be able to load/unload them as need be? Thanks, sorry if these questions are dumb ...

-rsa4046

Edit-

Okay, built kernel with sg and st as modules, modprobe st and modprobe sg, but rescan still doesn't find anything new. I even added the node myself:

```
 mknod -m 666 /dev/st0 c 9 0 
```

, but rescan still finds no new devices. Any ideas on what I'm doing wrong?Last edited by rsa4046 on Mon Aug 08, 2005 10:53 pm; edited 1 time in total

----------

## keyson

You can have the sg and st as modules (generic and tape)

As the generic driver is for scanners tapes cd-rom's -- everything

exept disks. The st (tape) is for tape drivers.

BUT DON'T SET SCSI Disk Support AS MODULE.

You must have scsi support and it is good to have legasy /proc/scsi

as some applications use it, and SCSI Disk support inkluded in the kernel,

othervise you would not be able to boot.

----------

## rsa4046

keyson:

See edit in previous post. Yes, thanks for the warning, I left disk support within the kernel. Just no luck with getting the bus to notice the fact that the tape drive is now on ...

----------

## keyson

Strange if the st0 is created if you have the tape powered under boot.

But not when you rescan the bus. Does the tapedrive show up in

the /proc/scsi/scsi when you do a rescan-scsi-bus?

EDIT: Btw you must have legacy /proc/scsi for the rescan script to work.Last edited by keyson on Mon Aug 08, 2005 11:12 pm; edited 1 time in total

----------

## rsa4046

keyson:

Okay, think I got it now:

I do:

```
# echo "scsi add-single-device 0 0 15 0" > /proc/scsi/scsi

```

and then the correct status is returned:

```

# cat /proc/scsi/scsiAttached devices:

Host: scsi0 Channel: 00 Id: 00 Lun: 00

  Vendor: SEAGATE  Model: ST373307LW       Rev: DS04

  Type:   Direct-Access                    ANSI SCSI revision: 03

Host: scsi0 Channel: 00 Id: 02 Lun: 00

  Vendor: TOSHIBA  Model: DVD-ROM SD-M1401 Rev: 1009

  Type:   CD-ROM                           ANSI SCSI revision: 02

Host: scsi0 Channel: 00 Id: 04 Lun: 00

  Vendor: PLEXTOR  Model: CD-R   PX-W1210S Rev: 1.06

  Type:   CD-ROM                           ANSI SCSI revision: 02

Host: scsi0 Channel: 00 Id: 10 Lun: 00

  Vendor: SEAGATE  Model: ST373307LW       Rev: DS04

  Type:   Direct-Access                    ANSI SCSI revision: 03

Host: scsi1 Channel: 00 Id: 00 Lun: 00

  Vendor: HP       Model: psc 2410         Rev: 1.00

  Type:   Direct-Access                    ANSI SCSI revision: 02

Host: scsi0 Channel: 00 Id: 15 Lun: 00

  Vendor: SONY     Model: SDX-450V         Rev: 0100

  Type:   Sequential-Access                ANSI SCSI revision: 02

# mt -f /dev/st0 status

SCSI 2 tape drive:

File number=-1, block number=-1, partition=0.

Tape block size 0 bytes. Density code 0x0 (default).

Soft error count since last status=0

General status bits on (50000):

 DR_OPEN IM_REP_EN

 

```

Success! Thanks alot for your help --

Cheers, rsa4046

----------

## rsa4046

One other wrinkle: the rescan script still doesn't pick up the drive, but cat /proc/scsi/scsi or lsscsi does (?)

```
# rescan-scsi-bus.sh -l 0 -w 1-15

/usr/bin/rescan-scsi-bus.sh: line 26: test: /sys/class/scsi_host/host0: binary operator expected

Host adapter 0 (aic7xxx) found.

Host adapter 1 (usb-storage) found.

Scanning hosts 0 -w 1-15 channels 0 for 

 SCSI target IDs  0 1 2 3 4 5 6 7 , LUNs  0 1 2 3 4 5 6 7

Scanning for device 0 0 0 0 ...

OLD: Host: scsi0 Channel: 00 Id: 00 Lun: 00

      Vendor: SEAGATE  Model: ST373307LW       Rev: DS04

      Type:   Direct-Access                    ANSI SCSI revision: 03

Scanning for device 0 0 2 0 ...

OLD: Host: scsi0 Channel: 00 Id: 02 Lun: 00

      Vendor: TOSHIBA  Model: DVD-ROM SD-M1401 Rev: 1009

      Type:   CD-ROM                           ANSI SCSI revision: 02

Scanning for device 0 0 4 0 ...

OLD: Host: scsi0 Channel: 00 Id: 04 Lun: 00

      Vendor: PLEXTOR  Model: CD-R   PX-W1210S Rev: 1.06

      Type:   CD-ROM                           ANSI SCSI revision: 02

0 new device(s) found.               

0 device(s) removed.                 

# lsscsi

[0:0:0:0]    disk    SEAGATE  ST373307LW       DS04  /dev/sda

[0:0:2:0]    cd/dvd  TOSHIBA  DVD-ROM SD-M1401 1009  /dev/sr0

[0:0:4:0]    cd/dvd  PLEXTOR  CD-R   PX-W1210S 1.06  /dev/sr1

[0:0:10:0]   disk    SEAGATE  ST373307LW       DS04  /dev/sdb

[0:0:15:0]   tape    SONY     SDX-450V         0100  /dev/st0

[1:0:0:0]    disk    HP       psc 2410         1.00  /dev/sdc

```

Anyways, Thanks again --

----------

## keyson

You can try.

```
rescan-scsi-bus.sh -l -w -c
```

As you se you get an error. You dont have to specify the range.

-l expands LUN scan from only 0 to 0 - 7 ( often devices only have 1 LUN)

-w expand ID search from 0-7 to 0-15 and

-c expand cannel search to 0 and 1.

----------

## rsa4046

keyson: 

You are right. I had the syntax wrong. If I do

```
rescan-scsi-bus.sh -w
```

the script does indeed find the Sony tape drive correctly:

```
/usr/bin/rescan-scsi-bus.sh: line 26: test: /sys/class/scsi_host/host0: binary o perator expected

Host adapter 0 (aic7xxx) found.

Host adapter 1 (usb-storage) found.

Scanning hosts  0 1 channels 0 for

 SCSI target IDs  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 , LUNs  0

Scanning for device 0 0 0 0 ...

OLD: Host: scsi0 Channel: 00 Id: 00 Lun: 00

      Vendor: SEAGATE  Model: ST373307LW       Rev: DS04

      Type:   Direct-Access                    ANSI SCSI revision: 03

Scanning for device 0 0 2 0 ...

OLD: Host: scsi0 Channel: 00 Id: 02 Lun: 00

      Vendor: TOSHIBA  Model: DVD-ROM SD-M1401 Rev: 1009

      Type:   CD-ROM                           ANSI SCSI revision: 02

Scanning for device 0 0 4 0 ...

OLD: Host: scsi0 Channel: 00 Id: 04 Lun: 00

      Vendor: PLEXTOR  Model: CD-R   PX-W1210S Rev: 1.06

      Type:   CD-ROM                           ANSI SCSI revision: 02

Scanning for device 0 0 10 0 ...

OLD: Host: scsi0 Channel: 00 Id: 10 Lun: 00

      Vendor: SEAGATE  Model: ST373307LW       Rev: DS04

      Type:   Direct-Access                    ANSI SCSI revision: 03

Scanning for device 0 0 15 0 ...

OLD: Host: scsi0 Channel: 00 Id: 15 Lun: 00

      Vendor: SONY     Model: SDX-450V         Rev: 0100

      Type:   Sequential-Access                ANSI SCSI revision: 02

Scanning for device 1 0 0 0 ...

OLD: Host: scsi1 Channel: 00 Id: 00 Lun: 00

      Vendor: HP       Model: psc 2410         Rev: 1.00

      Type:   Direct-Access                    ANSI SCSI revision: 02

0 new device(s) found.

0 device(s) removed.
```

Wow, I've learned alot from this. Thanks again and cheers!

----------

