[CentOS] Rescan /dev/sd* without reboot?

Tue Jul 1 22:00:39 UTC 2008
nate <centos at linuxpowered.net>

Scott Moseman wrote:
> I increased the SAN partition size for a given volume.  Is there a way
> I can have fdisk recognize the new size without a reboot?

This is an old way of doing it but it's worked fine for me over the
years.

cat /proc/scsi/scsi and find the device that you resized

Make sure the device is not in use(not mounted, not in use by device
mapper, multipathing software, LVM etc), assuming it is not:

echo "scsi remove-single-device X X X X" >/proc/scsi/scsi
echo "scsi add-single-device X X X X" >/proc/scsi/scsi

where X X X X is the id of the device, for example:

Contents of /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 06 Lun: 00
  Vendor: PE/PV    Model: 1x2 SCSI BP      Rev: 1.0
  Type:   Processor                        ANSI SCSI revision: 02
Host: scsi0 Channel: 01 Id: 00 Lun: 00
  Vendor: MegaRAID Model: LD 0 RAID1   69G Rev: 521S
  Type:   Direct-Access                    ANSI SCSI revision: 02

The disk above is the Megaraid volume which is "0 1 0 0".

You can check to be sure that the device disappears from /proc/scsi/scsi
after you remove it, before re-adding it. If the device is multpathed
then remove all instances of it from /proc/scsi/scsi. If you don't
know what ID it is your SAN device should be able to at least tell
you what LUN it's exported as, which should help in tracing down
which disk is which in /proc/scsi/scsi.

Careful with that command, if you remove a disk that is in use you can
seriously hose the system, often times requiring a hard power cycle.

nate