热添加磁盘

Centos添加硬盘时(SCSI -->系统上电运行过程只能添加SCSI硬盘),一般刚添加上系统不会识别到,我们重启后就可以识别出来了,是否有可以不重启系统即可识别出我们新添加的硬盘,其实可以的:

添加新的磁盘,查看/dev/ 此时并没有出现新的磁盘/dev/sdb:

[root@MiWiFi-R3-srv ~]# ls /dev/s
scd0      sda1      sda3      sg1       snapshot  stderr    stdout    
sda       sda2      sg0       shm/      sr0       stdin     systty    
[root@MiWiFi-R3-srv ~]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x000a47d7

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          52      409600   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              52         574     4194304   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             574        5222    37338112   83  Linux

确定主机总线号:

[root@MiWiFi-R3-srv ~]# ls /sys/class/scsi_host/
host0  host1  host2
[root@MiWiFi-R3-srv ~]# 

重新扫描SCSI总线来添加设备:

[root@MiWiFi-R3-srv ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@MiWiFi-R3-srv ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@MiWiFi-R3-srv ~]# echo "- - -" > /sys/class/scsi_host/host2/scan
[root@MiWiFi-R3-srv ~]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x000a47d7

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          52      409600   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              52         574     4194304   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             574        5222    37338112   83  Linux

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

[root@MiWiFi-R3-srv ~]# ls /dev/sd
sda   sda1  sda2  sda3  sdb   
comments powered by Disqus