How to Scan a New Disk in CentOS/RHEL Online (Without Reboot)

This post discusses - how to scan a new disk without rebooting the system. Sometimes the new disks are not scanned automatically and we need to troubleshoot the same. Let’s see an example here. My machine is running with “Red Hat Enterprise Linux Server release 6.3 (Santiago)”

I have 3 disks, 2 existing disks(2x10Gb), and one new 5GB disk to this machine added online. Now run the ‘fdisk –l | grep –i disk’ command to check whether the new disk detected or not.

# fdisk –l | grep –i disk
scan new disk online without reboot CentOS RHEL

It seems it is not detected. I can only see 2x10GBdisk in machine the new disk is not visible to the system. Since it is not visible to the system you need to rescan the scsi bus to get the new disk. Rescan can be issued using this command:

# echo "- - -" > /sys/class/scsi_host/host#/scan

Replace ‘host#’ with actual value such as host0 or host1 like this. You can find scsi_host value using the following command:

# ls /sys/class/scsi_host

Suppose if you have multiple scsi host values in the above command like what I have here.

# ls /sys/class/scsi_host
host0 host1 host2 host3 host4 host5 host6
host7 host8 host9 host10 host11 host11

Now you might be thinking how do I find the right scsi_hostvalue that you need to use with ’echo “- - -” > /sys/class/scsi_host/host#/scan’ command. The below 2 commands help you to find which is the correct scsi_host value you need to use.

# grep mpt /sys/class/scsi_host/host?/proc_name

This command output help you to get the scsi_host value. Here it is host2:

# grep mpt /sys/class/scsi_host/host?/proc_name
/sys/class/scsi_host/host2/proc_name:mptspi

The second option is to run the below command.

# udevadm info -a -p /sys/class/scsi_generic/sg0

The output of this command will be big however I am attaching the snippet of the portion that we need to look for scsi host value.

udevadm info scan device online

Once you have scsi_host value with you now you are ready for scanning the scsi bus.

# echo "- - -" > /sys/class/scsi_host/host2/scan

In my machine scsi_host value is host2.

Now just verify the /var/log/messages you could see some messages that the new disk is available in os. Similar to the below output:

online scan new disks in CentOS RHEL 7

Now you can run the ‘fdisk –l |grep –i disk’ command to confirm that the new disk is available to OS. I could see my new 5Gb (/dev/sdc) disk in the fdisk command now.

fdisk -l command output

Now you can create a partition using fdisk/cfdisk or parted, it’s up to you.