话不多说,直接开始
$ 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: Virtual disk Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 01 Lun: 00 Vendor: VMware Model: Virtual disk Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 $ echo "scsi add-single-device 2 0 2 0" > /proc/scsi/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: Virtual disk Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 01 Lun: 00 Vendor: VMware Model: Virtual disk Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 02 Lun: 00 Vendor: VMware Model: Virtual disk Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02
通过命令可以看到扫描到了新的磁盘,实现了不重启添加硬盘
$ echo "scsi add-single-device 2 0 2 0" > /proc/scsi/scsi 参数值 w、x、y 、 z,解释如下: w(Host)是主机适配器标识,第一个适配器为零(0) x (Channel)是主机适配器上的 SCSI 通道,第一个通道为零(0) y (ID)是设备的 SCSI 标识 z (Lun)是 LUN 号,第一个 LUN 为零(0)
1. 添加了磁盘后查看,没有刷新出来
[root@node /]# fdisk -l
Disk /dev/sda: 17.2 GB, 17179869184 bytes 255 heads, 63 sectors/track, 2088 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: 0x000aa84a
Device Boot Start End Blocks Id System /dev/sda1 * 1 2089 16775168 83 Linux /dev/sda2 2089 2089 1024 82 Linux swap / Solaris
2. 查看主机总线号
root@node /]# ls /sys/class/scsi_host/ host0 host1 host2
3.重新扫描SCSI总线来添加设备
[root@node /]# echo "- - -" > /sys/class/scsi_host/host0/scan [root@node /]# echo "- - -" > /sys/class/scsi_host/host1/scan [root@node /]# echo "- - -" > /sys/class/scsi_host/host2/scan
最后 fdisk -l 可以看到添加后的磁盘了
到此这篇关于vmware增加新硬盘无需重启即可生效的命令脚本的文章就介绍到这了,更多相关vmware增加新硬盘命令内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!