in SAN or iSCSI environment, usually multipath is envolved. In some circumstances, you will need add or remove a path to a Storage Device on the fly, here is how:

Removing a path to a Storage Device

If you are removing a path to a device that uses multipathing (without affecting other paths to the device), then the general procedure is as follows:

Removing a path to a Storage Device

1. Remove any reference to the device's path-based name, like /dev/sd or /dev/disk/bypath or the major: minor number, in applications, scripts, or utilities on the system. This is important in ensuring that different devices added in the future will not be mistaken for the current device.
2. Take the path offline using

echo offline > /sys/block/sd a/device/state

This will cause any subsequent I/O sent to the device on this path to be failed immediately. Device-map per-multipath will continue to use the remaining paths to the device.
3. Remove the path from the SCSI subsystem. To do so, use the command

echo 1 >/sys/block/device-name/device/delete 

After the path removed from SCSI, the path can be safely removed from the running system. It is not necessary to stop I/O while this is done, as Devicemap per-multipath will re-route I/O to remaining paths according to the configured path grouping and failover policies.


Other procedures, such as the physical removal of the cable, followed by a rescan of the SCSI bus to cause the operating system state to be updated to reflect the change, are not recommended. This will cause delays due to I/O timeouts, and devices may be removed unexpectedly. If it is necessary to perform a rescan of an interconnect, it must be done while I/O is paused

Adding a Storage Device or path

When adding a device, be aware that the path-based device name (/dev/sd name, major: minor number, and /dev/disk/by-path name, for example) the system assigns to the new device may have been previously in use by a device that has since been removed. As such, ensure that all old references to the path-based device name have been removed. Otherwise, the new device may be mistaken for the old device. However, if you are already using name friendly option, then you don't have to worry this part.

Add a Storage device or path

If you are adding a new Storage Device to the system, once the device apears to the system, udev and multipath will create the device names for the new storage device accordingly(depends on udev rules, and multipath.conf), you can reconfig the device names as you want. The following steps may not needed.

However, if you are just reattach a device back after resizing or maintenance, here is what you need to know.

1. The first step in adding a storage device or path is to physically enable access to the new storage device, or a new path to an existing device. This is done using vendor-specific commands at the Fibre Channel or iSCSI storage server. When doing so, note the LUN value for the new storage that will be presented to your host. If the storage server is Fibre Channel, also take note of the World Wide Node Name (WWNN) of the storage server, and determine whether there is a single WWNN for all ports on the storage server. If this is not the case, note the World Wide Port Name (WWPN) for each port that will be used to access the new LUN.
2. Next, make the operating system aware of the new storage device, or path to an existing device. The recommended command to use is:

$ echo "c t l" > /sys/class/scsi_host/hosth/scan

Where

h is the HBA number
c is the channel on the HBA
t is the SCSI target ID
l is the LUN

Note
The older form of this command is deprecated

echo "scsi add -single-device 0 0 0 0 " > /proc/scsi/scsi 

In some Fibre Channel hardware, a newly created LUN on the RAID array may not be visible to the operating system until a Loop Initialization Protocol (LIP) operation is performed.

Important
It will be necessary to stop I/O while this operation is executed if an LIP is required.
b. If a new LUN has been added on the RAID array but is still not being configured by the operating system, confirm the list of LUNs being exported by the array using the sg _luns command, part of the sg3_utils package. This will issue the SCSI REPORT LUNS command to the RAID array and return a list of LUNs that are present.
For Fibre Channel storage servers that implement a single WWNN for all ports, you can determine the correct h,c,and t values (i.e. HBA number, HBA channel, and SCSI target ID ) by searching for the WWNN in sysfs.

Determin correct h, c, and t values

For example, if the WWNN of the storage server is 0 x50 0 6 0 16 0 9 0 20 3181, use:

$ grep 5006016090203181 /sys/class/fc_transport/*/node_name
This should display output similar to the following:
/sys/class/fc_transport/target5:0:2/node_name:0x5006016090203181
/sys/class/fc_transport/target5:0:3/node_name:0x5006016090203181
/sys/class/fc_transport/target6:0:2/node_name:0x5006016090203181
/sys/class/fc_transport/target6:0:3/node_name:0x5006016090203181

This indicates there are four Fibre Channel routes to this target (two single-channel HBAs, each leading to two storage ports). Assuming a LUN value is 56 , then the following command will configure the first path:

$ echo "0 2 56" > /sys/class/scsi_host/host5/scan

This must be done for each path to the new device.
For Fibre Channel storage servers that do not implement a single WWNN for all ports, you can determine the correct HBA number, HBA channel, and SCSI target ID by searching for each of the WWPNs in sysfs.
Another way to determine the HBA number, HBA channel, and SCSI target ID is to refer to another device that is already configured on the same path as the new device. This can be done with various commands,

such as lsscsi , scsi_id , multipath -l , and ls -l /dev/disk/by-*. 

This information, plus the LUN number of the new device, can be used as shown above to probe and configure that path to the new device.
3. After adding all the SCSI paths to the device, execute the multipath command, and check to see that the device has been properly configured. At this point, the device can be added to md , LVM, mkfs, or mo unt, for example.
If the steps above are followed, then a device can safely be added to a running system. It is not necessary to stop I/O to other devices while this is done. Other procedures involving a rescan (or a reset) of the SCSI bus, which cause the operating system to update its state to reflect the current device connectivity, are not recommended while storage I/O is in progress.