红联Linux门户
Linux帮助

CentOS学习笔记--SCSI设备热插拔

发布时间:2015-09-20 19:21:47来源:linux网站作者:月上中天

处于运行中的服务器,因业务要求也许不允许重启机器,而新添加的SCSI设备(主要是硬盘)如何实现热插拔呢?


首先需要查看一下设备:

#cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
Type:   CD-ROM                           ANSI  SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: VMware,  Model: VMware Virtual S Rev: 1.0
Type:   Direct-Access                    ANSI  SCSI revision: 02


可以看到有两种设备:CD-ROM 和 Direct-Access 。

清楚SCSI设备后,就可以重新扫描新的设备了(例子是添加SCSI硬盘):

# echo "scsi add-single-device 2 0 1 0" >/proc/scsi/scsi
echo "scsi add-single-device a b c d" >/proc/scsi/scsi中
a 表示 SCSI的设备号,上面的Host:scsi后的数字,新添加就是同类型的那个数字,虚拟机中的scsi硬盘就是Direct-Access
b 表示 CHANNEL号,上面的channel,基本都是0
c 表示 ID号,新添加就是上面同类型的Id值+1
d 是LUN号 一般都为0


查看一下:

# cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
Type:   CD-ROM                           ANSI  SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: VMware,  Model: VMware Virtual S Rev: 1.0
Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi2 Channel: 00 Id: 01 Lun: 00
Vendor: VMware,  Model: VMware Virtual S Rev: 1.0
Type:   Direct-Access                    ANSI  SCSI revision: 02


看一下添加的SCSI硬盘:

# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ef79d
Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        2611    20458496   8e  Linux LVM
Disk /dev/mapper/VolGroup-lv_root: 18.8 GB, 18832424960 bytes
255 heads, 63 sectors/track, 2289 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdb: 10.7 GB, 10737418240 bytes              <---这个就是新添加的硬盘
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


后面就是sdb的分区了。


CentOS下如何搭建ISCSI以及Windows如何挂载ISCSI镜像:http://www.linuxdiyf.com/linux/13695.html

CentOS 6.4挂载iSCSI网络存储:http://www.linuxdiyf.com/linux/11446.html

CentOS 6.4系统存储服务器之iSCSI:http://www.linuxdiyf.com/linux/11389.html

CentOS 6.3下配置iSCSI网络存储:http://www.linuxdiyf.com/linux/10266.html