但是大家知道服务器是不能随便重启的,那么有什么好的方法可以不用重启就能识别新的硬盘吗?
答案是有的
步骤
在线添加一块磁盘
至于详细的虚拟机添加磁盘细节这里就不说了,都很简单,New Hard Disk就是新添加的磁盘
这时我们用fdisk -l 是看不到新添加的磁盘的
-
[root@steven ~]# 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: 0x0009a3b5
-
-
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/sdb: 1073 MB, 1073741824 bytes
-
255 heads, 63 sectors/track, 130 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: 0xf27bd8ef
-
-
Device Boot Start End Blocks Id System
-
/dev/sdb2 1 65 522081 5 Extended
-
/dev/sdb5 1 26 208782 8e Linux LVM
-
-
Disk /dev/mapper/VolGroup-lv_root: 19.0 GB, 19042140160 bytes
-
255 heads, 63 sectors/track, 2315 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
确定主机总线号,磁盘是有总线连接着的
-
[root@steven ~]# ls /sys/class/scsi_host/
- host0 host1 host2
重新扫描SCSI总线来添加设备,因为添加的是SCSI磁盘,所以扫描的是SCSI总线
-
[root@steven ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
-
[root@steven ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
- [root@steven ~]# echo "- - -" > /sys/class/scsi_host/host2/scan
验证
-
[root@steven ~]# 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: 0x0009a3b5
-
-
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/sdb: 1073 MB, 1073741824 bytes
-
255 heads, 63 sectors/track, 130 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: 0xf27bd8ef
-
-
Device Boot Start End Blocks Id System
-
/dev/sdb2 1 65 522081 5 Extended
-
/dev/sdb5 1 26 208782 8e Linux LVM
-
-
Disk /dev/mapper/VolGroup-lv_root: 19.0 GB, 19042140160 bytes
-
255 heads, 63 sectors/track, 2315 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/sdc: 1073 MB, 1073741824 bytes
-
255 heads, 63 sectors/track, 130 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/sdc就是新添加的磁盘 ,这样就实现了不重启在CentOS / RHEL 虚拟机中添加一块新硬盘