Usually when you add a new hard drive to the virtual machine, you may see that the new hard drive is not loaded automatically. This is because the SCSI bus connected to the hard disk needs to be rescan to make the new hard drive visible. Here is a simple command to rescan the SCSI bus and SCSI devices. The following steps have been tested in CentOS 7 and Rhel 7.
Add a new 20G hard drive to ESXi or vcenter:
Displays the current disk partition:
The code is as follows:
[Root@centos7 ~]# Fdisk-l
disk/dev/sda:32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * the bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk label Type:dos
Disk identifier:0x0006b96a
Device Boot Start End Blocks Id System
/DEV/SDA1 * 2048 1026047 512000 Linux
/dev/sda2 1026048 62914559 30944256 8e Linux LVM
disk/dev/mapper/centos-swap:2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * the bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
disk/dev/mapper/centos-root:29.5 GB, 29536288768 bytes, 57688064 sectors
Units = sectors of 1 * the bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Determine the host bus number
The code is as follows:
[Root@centos7 ~]# ls/sys/class/scsi_host/
Host0 host1 Host2
Re-scan the SCSI bus to add devices
The code is as follows:
[Root@centos7 ~]# echo "--" >/sys/class/scsi_host/host0/scan
[Root@centos7 ~]# echo "--" >/sys/class/scsi_host/host1/scan
[Root@centos7 ~]# echo "--" >/sys/class/scsi_host/host2/scan
Verify the disks and partitions and make sure that the 20GB hard drive has been added. In this example, the following line, "disk/dev/sdb:21.5 GB, 21474836480 bytes, 41943040 sectors", is available and confirms that a new disk has been added without restarting the server:
The code is as follows:
[Root@centos7 ~]# Fdisk-l
disk/dev/sda:32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * the bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk label Type:dos
Disk identifier:0x0006b96a
Device Boot Start End Blocks Id System
/DEV/SDA1 * 2048 1026047 512000 Linux
/dev/sda2 1026048 62914559 30944256 8e Linux LVM
disk/dev/mapper/centos-swap:2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * the bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
disk/dev/mapper/centos-root:29.5 GB, 29536288768 bytes, 57688064 sectors
Units = sectors of 1 * the bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
disk/dev/sdb:21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * the bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes