When you add a new hard disk to a VM, you may see that the new hard disk is not loaded automatically. This is because the SCSI bus connected to the hard disk needs to be scanned again to make the new hard disk visible. Here is a simple command to re-scan the SCSI bus and SCSI devices. The following steps have been tested in CentOS7 and RHEL7. Add a new 20 GB hard disk in ESXi or vCenter: displays the current disk partition: [root @ c
When you add a new hard disk to a VM, you may see that the new hard disk is not loaded automatically. This is because the SCSI bus connected to the hard disk needs to be scanned again to make the new hard disk visible. Here is a simple command to re-scan the SCSI bus and SCSI devices. The following steps have been tested in CentOS 7 and RHEL 7.
Add a new 20 GB hard disk in ESXi or vCenter:
Display the current disk partition:
[root@centos7 ~]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x0006b96a Device Boot Start End Blocks Id System/dev/sda1 * 2048 1026047 512000 83 Linux/dev/sda2 1026048 62914559 30944256 8e Linux LVMDisk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-root: 29.5 GB, 29536288768 bytes, 57688064 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes
Confirm host bus number
[root@centos7 ~]# ls /sys/class/scsi_host/host0 host1 host2
Re-scan the SCSI bus to add devices
[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 disk and partition and make sure that the 20 GB hard disk is added. In this example, the following line "Disk/dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors" appears and you can confirm that a new Disk is added without restarting the server:
[root@centos7 ~]# fdisk -lDisk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x0006b96a Device Boot Start End Blocks Id System/dev/sda1 * 2048 1026047 512000 83 Linux/dev/sda2 1026048 62914559 30944256 8e Linux LVMDisk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-root: 29.5 GB, 29536288768 bytes, 57688064 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes