User Tools

Site Tools


linux:discover_devices

Discover new devices

Remove old devices:

rescan-scsi-bus.sh --remove --alltargets --forcerescan

Rescan scsi bus, and recreate multipathing (mpath)

[root@centos01 ~]# scsi-rescan -a -m -r -l

Install sg3_utils and lsscsi package. scsi-rescan is an alias from rescan-scsi-bus.sh. Use oprion -r to remove paths or devices

[root@fedora01 ~]# /usr/bin/rescan-scsi-bus.sh -a
Host adapter 0 (mptspi) found.
Scanning SCSI subsystem for new devices
Scanning host 0 for  SCSI target IDs  0 1 2 3 4 5 6 7, LUNs  0 1 2 3 4 5 6 7 
[root@fedora01 ~]# lsscsi -s
[0:0:0:0]    disk    VMware   Virtual disk     2.0   /dev/sda   75.1GB
[0:0:20:0]   disk    VMware   Virtual disk     2.0   /dev/sdb   17.1GB
[0:0:21:0]   disk    VMware   Virtual disk     2.0   /dev/sdc   17.1GB
[1:0:0:0]    disk    IBM      2145             0000  /dev/sdd    137GB
[1:0:1:0]    disk    IBM      2145             0000  /dev/sde    137GB

If rescan not working (for all linux and also Ubuntu) try:

[root@ubuntu ~]# ls /sys/class/scsi_host/host*/scan
[root@ubuntu ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@ubuntu ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
for dev in $(ls /sys/class/scsi_host/host*/scan)
do
echo "- - -" > $dev
done

You can get the Fiber Channel addresses of the HBAs by typing the following commands:

# systool -c fc_host -v

Type the following command to determine the fibre channel target WWN:

# systool -c fc_transport -v

You will get node name (FC WWN) and port name of the storage processor port. Type the following command, to determine the mapping between SCSI HBTL addresses and the disks:

# sg_map -x
[root@fedora22 multipath]# dmsetup ls
fedora-swap	(253:0)
fedora-root	(253:1)
[root@fedora22 multipath]# dmsetup ls --tree
vgtest-lvmir (253:13)
 ├─vgtest-lvmir_mimage_1 (253:12)
 │  └─mpathep1 (253:8)
 │     └─mpathe (253:5)
 │        ├─ (8:112)
 │        └─ (8:64)
[root@fedora22 multipath]# lsscsi 
[0:0:1:0]    disk    AIX      VDASD            0001  /dev/sda 
[0:0:2:0]    cd/dvd  AIX      VOPTA                  /dev/sr0 
[root@fedora22 multipath]# lsblk 
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   50G  0 disk 
├─sda1            8:1    0    4M  0 part 
├─sda2            8:2    0  500M  0 part /boot
└─sda3            8:3    0 49.5G  0 part 
  ├─fedora-swap 253:0    0    2G  0 lvm  [SWAP]
  └─fedora-root 253:1    0 47.5G  0 lvm  /
sr0              11:0    1 1024M  0 rom  

Remove a device

If you want to remove a device for example a disk /dev/mapper/mapthb, remove his multipath device using:

[root@fedora22 multipath]# dmsetup remove mpathb

Remove multipath devices

[root@fedora22 multipath]# rescan-scsi-bus.sh -r

systool

# systool
Supported sysfs buses:
        scsi
        usb
...
Supported sysfs classes:
        sas_host
        scsi_device
        scsi_disk
        scsi_generic
        scsi_host
        usbmon
...
Supported sysfs devices:
        cpu
        system
...
Supported sysfs modules:
        tpm_tis
        usbnet
        vt
        xfs
...

# systool -c fc_host -v | more
Class = "fc_host"

  Class Device = "host5"
  Class Device path = "/sys/devices/pci0000:00/0000:00:03.0/0000:15:00.0/host5/fc_host/host5"
    dev_loss_tmo        = "30"
    fabric_name         = "0x1000000533b6dd57"
    issue_lip           = <store method only>
    max_npiv_vports     = "254"
    node_name           = "0x20000024ff3434e4"
    npiv_vports_inuse   = "0"
    port_id             = "0x010000"
    port_name           = "0x21000024ff3434e4"
    port_state          = "Online"
    port_type           = "NPort (fabric via point-to-point)"
    speed               = "8 Gbit"
    supported_classes   = "Class 3"
    supported_speeds    = "1 Gbit, 2 Gbit, 4 Gbit, 8 Gbit"
    symbolic_name       = "QLE2562 FW:v5.08.00 DVR:v8.04.00.08.06.4-k"
    system_hostname     = ""
    tgtid_bind_type     = "wwpn (World Wide Port Name)"
    uevent              =
    vport_create        = <store method only>
    vport_delete        = <store method only>

If you only want to get host5 info, then here you go

# systool -c fc_host -v -d host5
Well, module detail info
# systool -m qla2xxx -v
Module = "qla2xxx"

  Attributes:
    initstate           = "live"
    refcnt              = "288"
    srcversion          = "C5EBE96340369EB294E6D44"
    version             = "8.04.00.08.06.4-k"

  Parameters:
    ql2xallocfwdump     = "1"
    ql2xasynclogin      = "1"
...

To get HBA info

# systool -c fc_host -A port_name
Class = "fc_host"

  Class Device = "host5"
    port_name           = "0x21000024ff3434e4"

    Device = "host5"


  Class Device = "host6"
    port_name           = "0x21000024ff3434e5"

    Device = "host6"

Check scsi disk path

# systool -c scsi_disk  -d 0:5:0  -p           
Class = "scsi_disk"

  Class Device = "0:5:0"
  Class Device path = "/sys/devices/pci0000:00/0000:00:03.0/0000:15:00.0/host5/rport-5:0-7/target5:0:5/5:0:5:0/scsi_disk/5:0:5:0"
    Device = "5:0:5:0"
    Device path = "/sys/devices/pci0000:00/0000:00:03.0/0000:15:00.0/host5/rport-5:0-7/target5:0:5/5:0:5:0"


  Class Device = "0:5:0"
  Class Device path = "/sys/devices/pci0000:00/0000:00:03.0/0000:15:00.1/host6/rport-6:0-8/target6:0:5/6:0:5:0/scsi_disk/6:0:5:0"
    Device = "6:0:5:0"
    Device path = "/sys/devices/pci0000:00/0000:00:03.0/0000:15:00.1/host6/rport-6:0-8/target6:0:5/6:0:5:0"

Get usb info

# systool -b usb -d usb1  -v
Bus = "usb"

  Device = "usb1"
  Device path = "/sys/devices/pci0000:00/0000:00:1a.7/usb1"
    authorized          = "1"
...

Check local disk

#  systool -c scsi_disk -v 1:0:0
Class = "scsi_disk"

  Class Device = "1:0:0"
  Class Device path = "/sys/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/host0/target0:1:0/0:1:0:0/scsi_disk/0:1:0:0"
    FUA                 = "0"
    allow_restart       = "0"
    app_tag_own         = "0"
    cache_type          = "write through"
    manage_start_stop   = "0"
    protection_mode     = "none"
    protection_type     = "0"
    provisioning_mode   = "full"
    thin_provisioning   = "0"
    uevent              =

    Device = "0:1:0:0"
    Device path = "/sys/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/host0/target0:1:0/0:1:0:0"
      delete              = <store method only>
      device_blocked      = "0"
      dh_state            = "detached"
      evt_media_change    = "0"
      iocounterbits       = "32"
      iodone_cnt          = "0x28eab"
      ioerr_cnt           = "0x35"
      iorequest_cnt       = "0x28eab"
      modalias            = "scsi:t-0x00"
      model               = "Logical Volume  "
      queue_depth         = "128"
      queue_ramp_up_period= "120000"
      queue_type          = "simple"
      rescan              = <store method only>
      rev                 = "3000"
      sas_address         = "0x0396c469eb687835"
      sas_device_handle   = "0x00b5"
      scsi_level          = "7"
      state               = "running"
      timeout             = "30"
      type                = "0"
      uevent              = "DEVTYPE=scsi_device
DRIVER=sd
MODALIAS=scsi:t-0x00"
      vendor              = "LSI     "

FC remote port info
#  systool -c fc_remote_ports -v -d 0-8
Class = "fc_remote_ports"

  Class Device = "0-8"
  Class Device path = "/sys/devices/pci0000:00/0000:00:03.0/0000:15:00.0/host5/rport-5:0-8/fc_remote_ports/rport-5:0-8"
    dev_loss_tmo        = "30"
    fast_io_fail_tmo    = "off"
    node_name           = "0x20000024ff3434d4"
    port_id             = "0x010200"
    port_name           = "0x21000024ff3434d4"
    port_state          = "Online"
    roles               = "FCP Initiator"
    scsi_target_id      = "-1"
    supported_classes   = "Class 3"
    uevent              =

    Device = "rport-5:0-8"
    Device path = "/sys/devices/pci0000:00/0000:00:03.0/0000:15:00.0/host5/rport-5:0-8"
      uevent              =


  Class Device = "0-8"
  Class Device path = "/sys/devices/pci0000:00/0000:00:03.0/0000:15:00.1/host6/rport-6:0-8/fc_remote_ports/rport-6:0-8"
    dev_loss_tmo        = "30"
    fast_io_fail_tmo    = "off"
    node_name           = "0x20060080e52d2652"
    port_id             = "0x011200"
    port_name           = "0x20460080e52d2652"
    port_state          = "Online"
    roles               = "FCP Target"
    scsi_target_id      = "5"
    supported_classes   = "Class 3"
    uevent              =

    Device = "rport-6:0-8"
    Device path = "/sys/devices/pci0000:00/0000:00:03.0/0000:15:00.1/host6/rport-6:0-8"
      uevent              =

Rescan Iscsi

iscsiadm -m session                     # Obtain the list of all the current sessions 	
iscsiadm -m session --sid=N --rescan    # Rescan a specific session N is the specific session ID.
iscsiadm -m session --rescan            # Rescan all the sessions 	
/usr/bin/rescan-scsi-bus.sh             # Rescan using the SCSI rescan script 	
linux/discover_devices.txt · Last modified: 2022/03/20 22:05 by manu