Linux/SCSI

From Omnia
Jump to: navigation, search

Linux - Rescan SCSI bus without reboot

Kernel Korner - Storage Improvements for 2.6 and 2.7

Because most RAID arrays allow LUNs to be created, removed and resized dynamically, it is important that the Linux kernel to react to these actions, preferably without a reboot. The Linux 2.6 kernel permits this by way of the /sys filesystem, which replaced the earlier /proc interfaces. For example, the following command causes the kernel to forget about the LUN on busid 3, channel 0, target 7 and LUN 1:

echo "1" > \
/sys/class/scsi_host/host3/device/3:0:7:1/delete

To scan all channels, targets and LUNs, try:

echo "- - -" > /sys/class/scsi_host/host3/scan


hd online without a reboot - Usenet Forums

"download http://www.garloff.de/kurt/linux/rescan-scsi-bus.sh and use that shell

script to rescan the SCSI bus and pick up any new devices that have been attached. Try it with the --help option first so you know everything that it can do."

Just a final note on this one in case someone googles it out...

The script mentioned by Dances With QuestionMarks actually scans the bus but then uses the echo method of bringing the scsi device online in the kernel. If you want to bring a single device online or more take a device offline the actual commands are listed below.

Don

From the SCSI Programmers Guide:

To remove a SCSI device:

echo "scsi remove-single-device a b c d" > /proc/scsi/scsi

and similar, to add a SCSI device, do

echo "scsi add-single-device a b c d" > /proc/scsi/scsi

where

a == hostadapter id (first one being 0)
b == SCSI channel on hostadapter (first one being 0)
c == ID
d == LUN (first one being 0)


CentOS - Rescan /dev/sd* without reboot?

echo "- - -" > /sys/class/scsi_host/host?/scan

replacing ? with the proper scsi/fiberchannel host channel #


sysdigg: Add SAN disks on RHEL without reboot

"On HP Proliant or HP blade server running Red Hat Enterprise Linux 4 (AS/ES) SAN disks or newly created LUN can be added on the fly without doing Linux reboot. Since HP proliant uses Qlogic HBA make sure you have latest Qlogic driver installed on your Red Hat enterprise Linux server. "
"Rescan your qlogic HBA's"
echo "scsi-qlascan" > /proc/scsi/<driver-name>/<adapter-id>
echo "scsi add-single-device 0 1 2 3" >/proc/scsi/scsi
echo "scsi-qlascan" > /proc/scsi/qla2200/1
echo "scsi-qlascan" > /proc/scsi/qla2200/2
echo "scsi add-single-device 1 0 0 6" >/proc/scsi/scsi


rescan the SCSI-Bus without reboot - linux.scsi.ncr53c8xx | Google Groups:

# Activate cdr drive if it was off.
#      * Usage: echo "scsi add-single-device 0 1 2 3" >/proc/scsi/scsi
#      * with  "0 1 2 3" replaced by your "Host Channel Id Lun".
#      * Consider this feature BETA.
#      *     CAUTION: This is not for hotplugging your peripherals. As
#      *     SCSI was not designed for this you could damage your
#      *     hardware !                                                  
echo "scsi add-single-device 1 0 6 0" >/proc/scsi/scsi

Note that I have 2 scsi cards, you probably want a host of 0. 


Kurt Garloff - Linux: My Contributions to free software

Rescan SCSI bus Linux allows you to add and remove SCSI devices without rebooting by using the echo "scsi add-single-device H C I L" > /proc/scsi/scsi command (H = host, C = channel, I = SCSI ID, L = SCSI LUN). The remove-single-device command works similarily. Note, however, that the SCSI bus was NOT designed for hot-plugging, so you might be out of luck ... And you have to be sure, that termination is OK. All filesystems on a device have to be unmounted before disconnecting it or powering it down.

I use the script rescan-scsi-bus.sh to do this.

v1.29 (2008-10-29)


Red Hat Knowledgebase: How do I get the kernel to recognize a hot-added SCSI drive or change the logging/dump detail level for the SCSI sub-system?:

Symptom: You have a SCSI controller and the kernel does not see a newly added SCSI drive.

Solution:

Rebooting the system is still the only supported method for adding a new SCSI device to a running system.

Assuming that you have the necessary permissions for writing to /proc/scsi/scsi. The following are some individual commands available for viewing/manipulating scsi controllers and devices:

*echo "scsi add-single-device <H> <C> <I> <L>" > /proc/scsi/scsi where <H> <C> <I> <L> represents
 Host <H>, Channel <C>, Id <I>, and Lun <L>. Will add the device specified so that it is accessible
 to the system.

*echo "scsi remove-single-device <H> <C> <I> <L>" > /proc/scsi/scsi where <H> <C> <I> <L> represents
 Host <H>, Channel <C>, Id <I>, and Lun <L>. Will remove the device specified so that it is no
 longer accessible to the system.

*echo "scsi scan-new-devices" > /proc/scsi/scsi will scan all host adapters again to see if there are
 any new devices.

*echo "scsi dump <#>" > /proc/scsi/scsi will dump the status of all current SCSI commands. <#> is the
 number specifing the level of detail for the dump, 0-9 are valid.

*echo "scsi log <T> <#>" > /proc/scsi/scsi will change the detail level of SCSI logging represented
 by <T> of error, scan, mlqueue, mlcomplete, llqueue, llcomplete, hlqueue, or hlcomplete, to the level
 specified by the <#> number. 

scu

SCSI Command Utility (scu) - http://www.scsifaq.org/RMiller_Tools/scu.html

scu Command Summary - http://www.scsifaq.org/RMiller_Tools/scu/scu-scsi-summary.pdf

If trying to run on 64bit:

yum install glibc.i686

Quick installation:

cd ~
wget http://www.scsifaq.org/RMiller_Tools/ftp/linux/intel-scu.tar.gz
tar -zvxf intel-scu.tar.gz
cd scu.d
ln -s ~/scu.d/scu /usr/local/bin/scu

Help:

./scu help

Select device:

./scu -f /dev/sdb

Execute a command from shell: (will return a non-zero errcode on failure)

scu -f /dev/sdc show capacity

General Commands:

show version     # show scu version

exit             # exit scu
quit             # exit scu

switch /dev/sdb  # switch devices

pwd              # print working device
show nexus       # print working device

tur              # test unit ready

show capacity    # show disk capacity

Can use short versions:

sw - switch
cat > scu-test <<EOF

set debug on
pwd

show edt
show edt cap
show edt status
show edt serial

show nexus
show capacity
show edt lun 0
show pages
show inquiry
show mode
show inquiry pages supported

show log pages supported
show log pages
zero log pages
show log page overrun
show log pages all

rezero

show capacity
verify media starting 409700 dbbr on
verify media starting 1000 length 1024

show defects grown

show sense

time format defects primary options dcrt
time format defects primary options immed

write same starting 4100000 bs 1m
write media starting 4110000 popts lbdata
read media starting 4110000 popts lbdata

dump media lba 4110000
eval 0x003eb6b0

mbad lba 4110400
mbad lba 4110400 hard
write media lba 4110400
read media lba 4110400 compare off
read media bs 1m limit 10m compare off
read media bs 64k limit 11m errors 1

show stats
set stats on
read media bs 1m limit 100m compare off
read media starting 1000 length 1024

show scsi key 6
show scsi status 0x28

show paths all
show paths all cap

show inquiry pages supported
show inquiry pages
show inquiry page serial

show edt bus 0 target 1 lun 0 full

show luns

# test unit ready
tur

test memory
test selftest

exit
EOF


cat scu-test | ./scu -f /dev/sdb

scu-scsi-summary.pdf - http://www.scsifaq.org/RMiller_Tools/scu/scu-scsi-summary.pdf

other scsi tools

keywords