1、查看硬盘
[root@linux-host1 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 20G 0 disk ├─sda1 8:1 0 1G 0 part /boot└─sda2 8:2 0 19G 0 part ├─centos-root 253:0 0 17G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm[SWAP]sr0 11:0 1 1G 0 rom # 没有检查到sdb的硬盘
2.检查当前系统有多少。host目录
[root@linux-host1 ~]# ls /sys/class/scsi_host/ -ltotal 0lrwxrwxrwx. 1 root root 0 Sep 16 12:42 host0 -> ../../devices/pci0000:00/0000:00:10.0/host0/scsi_host/host0lrwxrwxrwx. 1 root root 0 Sep 16 12:42 host1 -> ../../devices/pci0000:00/0000:00:07.1/ata1/host1/scsi_host/host1lrwxrwxrwx. 1 root root 0 Sep 16 12:42 host2 -> ../../devices/pci0000:00/0000:00:07.1/ata2/host2/scsi_host/host2
3、有多少个host就往多少个host目录中的文件scan追加"- - -"
[root@linux-host1 ~]# echo "- - -"> /sys/class/scsi_host/host0/scan[root@linux-host1 ~]# echo "- - -"> /sys/class/scsi_host/host1/scan[root@linux-host1 ~]# echo "- - -"> /sys/class/scsi_host/host2/scan
4.再次检查硬盘是否已识别
[root@linux-host1 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 20G 0 disk ├─sda1 8:1 0 1G 0 part /boot└─sda2 8:2 0 19G 0 part ├─centos-root 253:0 0 17G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm[SWAP]sdb 8:16 0 20G 0 disk <<已成功识别sr0 11:0 1 1G 0 rom
一键执行shell脚本
#!/bin/bashscsisum=`ls -l /sys/class/scsi_host/host*|wc -l`for ((i=0;i<${scsisum};i ))do echo "- - -" > /sys/class/scsi_host/host${i}/scandone
路由