CentOS/RHEL: Removing and adding new disk, not showing correct size (EMC storage)

The Problem

Two LUNs of 20 GB were removed and new LUNs of 240GB presented to the server. EMC storage is used. Below we can see the incorrect size:

# multipath -ll mpath1
mpath1 (36000144000000010600aa302e54d98da) dm-19 EMC,Invista
size=20G features='0' hwhandler='0' wp=rw
`-+- policy='queue-length 0' prio=1 status=active
 |- 0:0:0:17 sdr 65:16 active ready running
 |- 0:0:1:17 sdmj 69:432 active ready running
 |- 1:0:1:17 sdble 128:1600 active ready running
 `- 1:0:0:17 sdaym 67:1440 active ready running
# fdisk -l /dev/sdr

Disk /dev/sdr: 21.5 GB, 21475491840 bytes
255 heads, 63 sectors/track, 2610 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: 0xbaac3a38

  Device Boot Start End Blocks Id System
/dev/sdr1 1 2610 20964761 83 Linux

The Solution

If the LUNs are not being in use yet please do the following steps:

Example using LUN mpath1:

mpath1 (36000144000000010600aa302e54d98da) dm-19 EMC,Invista
size=20G features='0' hwhandler='0' wp=rw
'-+- policy='queue-length 0' prio=1 status=active
|- 0:0:0:17 sdr 65:16 active ready running
|- 0:0:1:17 sdmj 69:432 active ready running
|- 1:0:1:17 sdble 128:1600 active ready running
'- 1:0:0:17 sdaym 67:1440 active ready running

1. Remove the scsi device’s that are showing incorrect size:

Example :

echo 1 > /sys/block/sdr/device/delete
echo 1 > /sys/block/sdmj/device/delete
echo 1 > /sys/block/sdble/device/delete
echo 1 > /sys/block/sdaym/device/delete

2. Rescan the scsi devices on the server after deleting all the scsi devices that are showing the incorrect size of the LUNs. Run the Emulex scan script provided by Emulex or rescan-scsi-bus.sh or the below commands.

Rescan SCSI hosts:

# for host in `ls /sys/class/scsi_host`
do
	echo ${host}; echo "- - -" > /sys/class/scsi_host/${host}/scan
done

Issue LIP to FC hosts:

# for host in `ls /sys/class/fc_host`
do
	echo ${host}; echo "1" > /sys/class/fc_host/${host}/issue_lip
done

3. After doing the scan run multipath -ll and verify that theLUN has the correct size now:

# multipath -ll mpath1
mpath1 (36000144000000010600aa302e54d98da) dm-19 EMC,Invista
size=240G features='0' hwhandler='0' wp=rw
'-+- policy='queue-length 0' prio=1 status=active
|- 0:0:0:17 sdr 65:16 active ready running
|- 0:0:1:17 sdmj 69:432 active ready running
|- 1:0:1:17 sdble 128:1600 active ready running
'- 1:0:0:17 sdaym 67:1440 active ready running