LINUXOR.SK ... open source notes ...

Linux Storage - SCSI bus rescan

category: solutionz · date: 2013-12-31 · updated: 2026-10-03 · author: LALA

Linux Storage Solution · Config document · referenced from LUNs seen and SCSI bus rescan

noteThe manual rescan line carries the placeholder <hostN> where the notes had a reminder to fill in the host number; it is not a command to paste as it stands. The scsi-rescan output lists the LUNs of each FC host in the order 0, 1, 2, 254, 3, 4, 5, not in numeric order; see the explanation after it.

The three ways the notes rescan the SCSI bus of HV01 for new LUNs: the scsi-rescan script (the rescan-scsi-bus.sh tool), the manual write of - - - into the scan attribute of one SCSI host, and a one-line loop that does the same for every FC host. Everything ran as root on HV01. The two echo forms write into sysfs and trigger a scan; scsi-rescan was run against a bus where every LUN was already present, so it found nothing new.

ItemValue
Paths written/sys/class/scsi_host/<hostN>/scan, here host1 and host2; the loop takes the names from /sys/class/fc_host
On which hostHV01, the first blade (HP BL660c Gen8)
Run asroot
Toolscsi-rescan, that is rescan-scsi-bus.sh; the notes link http://www.garloff.de/kurt/linux/#rescan-scsi as its home and give no version
Result0 new device(s) found., 0 device(s) removed.; every device was already known
Devices before and after16, as in /proc/scsi/scsi

The commands

The first way: the script. It walks every host adapter and probes the known devices and the free addresses.

bash
$ scsi-rescan
output 73 lines
Host adapter 0 (hpsa) found.
Host adapter 1 (qla2xxx) found.
Host adapter 2 (qla2xxx) found.
Scanning SCSI subsystem for new devices
Scanning host 0 for  SCSI target IDs  0 1 2 3 4 5 6 7, all LUNs
Scanning for device 0 0 0 0 ...
OLD: Host: scsi0 Channel: 00 Id: 00 Lun: 00
      Vendor: HP       Model: LOGICAL VOLUME   Rev: 4.68
      Type:   Direct-Access                    ANSI SCSI revision: 05
Scanning for device 0 3 0 0 ...
OLD: Host: scsi0 Channel: 03 Id: 00 Lun: 00
      Vendor: HP       Model: P220i            Rev: 4.68
      Type:   RAID                             ANSI SCSI revision: 05
Scanning host 1 for  all SCSI target IDs, all LUNs
Scanning for device 1 0 0 0 ...
OLD: Host: scsi1 Channel: 00 Id: 00 Lun: 00
      Vendor: 3PARdata Model: VV               Rev: 3122
      Type:   Direct-Access                    ANSI SCSI revision: 06
Scanning for device 1 0 0 1 ...
OLD: Host: scsi1 Channel: 00 Id: 00 Lun: 01
      Vendor: 3PARdata Model: VV               Rev: 3122
      Type:   Direct-Access                    ANSI SCSI revision: 06
Scanning for device 1 0 0 2 ...
OLD: Host: scsi1 Channel: 00 Id: 00 Lun: 02
      Vendor: 3PARdata Model: VV               Rev: 3122
      Type:   Direct-Access                    ANSI SCSI revision: 06
Scanning for device 1 0 0 254 ...
OLD: Host: scsi1 Channel: 00 Id: 00 Lun: 254
      Vendor: 3PARdata Model: SES              Rev: 3122
      Type:   Enclosure                        ANSI SCSI revision: 06
Scanning for device 1 0 0 3 ...
OLD: Host: scsi1 Channel: 00 Id: 00 Lun: 03
      Vendor: 3PARdata Model: VV               Rev: 3122
      Type:   Direct-Access                    ANSI SCSI revision: 06
Scanning for device 1 0 0 4 ...
OLD: Host: scsi1 Channel: 00 Id: 00 Lun: 04
      Vendor: 3PARdata Model: VV               Rev: 3122
      Type:   Direct-Access                    ANSI SCSI revision: 06
Scanning for device 1 0 0 5 ...
OLD: Host: scsi1 Channel: 00 Id: 00 Lun: 05
      Vendor: 3PARdata Model: VV               Rev: 3122
      Type:   Direct-Access                    ANSI SCSI revision: 06
Scanning host 2 for  all SCSI target IDs, all LUNs
Scanning for device 2 0 0 0 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 00
      Vendor: 3PARdata Model: VV               Rev: 3122
      Type:   Direct-Access                    ANSI SCSI revision: 06
Scanning for device 2 0 0 1 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 01
      Vendor: 3PARdata Model: VV               Rev: 3122
      Type:   Direct-Access                    ANSI SCSI revision: 06
Scanning for device 2 0 0 2 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 02
      Vendor: 3PARdata Model: VV               Rev: 3122
      Type:   Direct-Access                    ANSI SCSI revision: 06
Scanning for device 2 0 0 254 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 254
      Vendor: 3PARdata Model: SES              Rev: 3122
      Type:   Enclosure                        ANSI SCSI revision: 06
Scanning for device 2 0 0 3 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 03
      Vendor: 3PARdata Model: VV               Rev: 3122
      Type:   Direct-Access                    ANSI SCSI revision: 06
Scanning for device 2 0 0 4 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 04
      Vendor: 3PARdata Model: VV               Rev: 3122
      Type:   Direct-Access                    ANSI SCSI revision: 06
Scanning for device 2 0 0 5 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 05
      Vendor: 3PARdata Model: VV               Rev: 3122
      Type:   Direct-Access                    ANSI SCSI revision: 06
0 new device(s) found.
0 device(s) removed.

The second way: the manual rescan of one SCSI host. The notes wrote a reminder in place of the host number, "fill in, usually the last two", which is <hostN> here; on HV01 the last two are host1 and host2. The trailing semicolon is in the notes.

bash
$ echo "- - -" > /sys/class/scsi_host/<hostN>/scan;

The third way: the author's one-line loop over every FC host, which the notes call a small script in bash style. It rescans every FC SCSI device and no other host.

bash
$ for host in `ls /sys/class/fc_host`; do echo "- - -" > /sys/class/scsi_host/${host}/scan; done

What the lines mean

Line or valueMeaning
Host adapter N (driver) found.the script found three SCSI hosts: host0 with hpsa (the HP P220i), host1 and host2 with qla2xxx (the two HBA ports)
Scanning host 0 for SCSI target IDs 0 1 2 3 4 5 6 7, all LUNson the local controller the script probes target IDs 0 to 7; on the FC hosts it says all SCSI target IDs
Scanning for device H C T L ...the address being probed, host, channel, target, LUN
OLD:the device at that address was already known to the kernel; a new one would print NEW: and the /proc/scsi/scsi style block below it, as I understand the script
0 new device(s) found., 0 device(s) removed.the result: nothing changed
- - -the three fields the kernel's scan attribute takes, channel, target and LUN; a - means "all", so the host scans every channel, every target and every LUN. My understanding of the kernel interface; the notes do not explain the dashes
the backquoted ls /sys/class/fc_hostthe loop takes the host names, host1 and host2, from the FC host class and writes the scan request into the scsi_host entry of the same name

The LUNs of host1 and host2 are scanned in the order 0, 1, 2, 254, 3, 4, 5. The notes do not remark on it. My reading is that the script lists the devices already present and sorts them as strings, so 254 falls between 2 and 3; it is an inference and I did not confirm it in the script's source.

Checked against sg3_utils 1.49, RHEL 10.2 and SLES 15 SP7

As builtToday
scsi-rescan from the garloff.de pagerescan-scsi-bus.sh now lives in the sg3_utils repository (scripts/rescan-scsi-bus.sh, script version 20260526 in the current tree; sg3_utils release 1.49, RHEL 9 ships 1.47, RHEL 10 1.48, SLES 15 SP7 and 16.0 1.48) and still writes channel id lun or channel - - into /sys/class/scsi_host/hostN/scan
the name scsi-rescanA Red Hat and Fedora symlink: the Fedora package links scsi-rescan to rescan-scsi-bus.sh and ships a manual page for it, the openSUSE and upstream packages do not. It works on RHEL-family systems and not on SLES
echo "- - -" > /sys/class/scsi_host/<hostN>/scanThe scan attribute still exists in the kernel, but Red Hat no longer shows the wildcard: the RHEL 7 guide recommended echo "c t l" > with the exact address, and the RHEL 9 and 10 guides document only echo 1 > /sys/block/sdX/device/rescan after a LUN resize and issue_lip on the FC host. SLES 15 SP7 documents rescan-scsi-bus.sh [-a] [-r] --hosts=2-3,5 and warns against using it with EMC PowerPath
run once, every LUN presentThe RHEL 7 guide listed the script's known issues: LUN 0 must be mapped first, and when LUNs are mapped for the first time the script may have to run twice

The loop over /sys/class/fc_host would still work on any current kernel; whether a vendor wants it run on a host with multipathing is a question for that vendor's guide.

← solutionz