linux添加磁盘后动态加载

CSI接口具有应用范围广、多任务、带宽大、CPU占用率低,以及热插拔等优点,在服务器中广泛的应用。

当然在虚拟化平台支持下,也能模拟出SCSI设备,方便在虚拟机上热添加SCSI设备(一般是硬盘)

但是在热添加SCSI设备之后,需要手动rescan SCSI设备。

比较常见的做法是输入如下命令

echo “- - -” > /sys/class/scsi_host/host*/scan

CentOS/RHEL5.9开始(SUSE11/12也有这个工具)提供一个工具包sg3_utils同样可以方便的实现rescan操作

# yum install sg3_utils
# /usr/bin/rescan-scsi-bus.sh

即可rescan SCSI设备 ,如果找不到磁盘,可以执行如下操作

1、找到总线编号
[root@mail ~]# grep mpt /sys/class/scsi_host/host?/proc_name
/sys/class/scsi_host/host2/proc_name:mptspi

2、扫描SCSI总线,请注意host后面的数字0,需根据上面实际查出的总线编号一样,我这里是2

[root@mail ~]# echo "- - -" > /sys/class/scsi_host/host2/scan

3、运行fdisk -l 就可以看到新添加的硬盘了
# /usr/bin/rescan-scsi-bus.sh --help
Usage: rescan-scsi-bus.sh [options] [host [host ...]]
Options:
 -a      scan all targets, not just currently existing [default: disabled]
 -d      enable debug                       [default: 0]
 -l      activates scanning for LUNs 0--7   [default: 0]
 -L NUM  activates scanning for LUNs 0--NUM [default: 0]
 -w      scan for target device IDs 0--15   [default: 0--7]
 -c      enables scanning of channels 0 1   [default: 0 / all detected ones]
 -m      update multipath devices           [default: disabled]
 -r      enables removing of devices        [default: disabled]
 -f      flush failed multipath devices     [default: disabled]
 -i      issue a FibreChannel LIP reset     [default: disabled]
 -u      look for existing disks that have been remapped
 -s      look for resized disks and reload associated multipath devices, if applicable
--alltargets:    same as -a
--remove:        same as -r
--flush:         same as -f
--issue-lip:     same as -i
--wide:          same as -w
--multipath:     same as -m
--forceremove:   Remove stale devices (DANGEROUS)
--forcerescan:   Remove and readd existing devices (DANGEROUS)
--nooptscan:     don't stop looking for LUNs if 0 is not found
--color:         use coloured prefixes OLD/NEW/DEL
--hosts=LIST:    Scan only host(s) in LIST
--channels=LIST: Scan only channel(s) in LIST
--ids=LIST:      Scan only target ID(s) in LIST
--luns=LIST:     Scan only lun(s) in LIST
--sync/nosync:   Issue a sync / no sync [default: sync if remove]
--attachpq3:     Tell kernel to attach sg to LUN 0 that reports PQ=3
--reportlun2:    Tell kernel to try REPORT_LUN even on SCSI2 devices
--largelun:      Tell kernel to support LUNs > 7 even on SCSI2 devs
--sparselun:     Tell kernel to support sparse LUN numbering
--update:        same as -u
--resize:        same as -s
 Host numbers may thus be specified either directly on cmd line (deprecated) or
 or with the --hosts=LIST parameter (recommended).
LIST: A[-B][,C[-D]]... is a comma separated list of single values and ranges
 (No spaces allowed.)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值