Array Setup and Networking
1752749 Members
5171 Online
108789 Solutions
New Discussion

Use IQN string as device name in Linux with multipathing

 
aherbert23
Trusted Contributor

Use IQN string as device name in Linux with multipathing

Sometimes it's difficult to know which device is which under Linux. Even more difficult when adding in the multipathing layer. This can all be remedied with a custom script and a few modifications to the multipath.conf file. The multipath.conf file has a parameter for creating a custom callout script for naming and grouping devices. The default is to use the SCSI ID of the device. This is how multipathd knows which devices should be grouped together. This custom script will use the unique IQN string of the device which will make identifying the device later through device mapper much easier.

The first step is to create a file /usr/local/sbin/iscsi_id.sh with the following content and set it as executable.


#!/bin/bash



ls -l /dev/disk/by-path/ | egrep iscsi | egrep "$1$" | sed -e 's/.*:\([a-z0-9.:-]*\).*/\1/'






Then modify the /etc/multipath.conf file with the getuid_callout variable on line 32 to point to the new script.


defaults {


  path_grouping_policy multibus


  rr_min_io 20


}



blacklist {


  devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"


  devnode "^hd[a-z][[0-9]*]"


  device {


    vendor "*"


    product "*"


  }


}



blacklist_exceptions {


  device {


    vendor "Nimble"


    product "Server"


  }


}



devices {


  device {


    vendor "Nimble"


    product "Server"


    path_selector "round-robin 0"


    path_grouping_policy group_by_serial


    path_checker tur


    rr_min_io 20


    failback manual


    rr_weight priorities


    getuid_callout "/usr/local/sbin/iscsi_id.sh %n"


  }


}






Once these changes are in place listing /dev/mapper makes the time spent making this modification worth all the effort.


ls -l /dev/mapper/


total 0


crw------- 1 root root 10, 236 Dec 17 08:48 control


lrwxrwxrwx 1 root root       7 Dec 17 13:28 mysql-clone-v16da9ef36265f874.000001dd.74bf6687-lun-0 -> ../dm-2


lrwxrwxrwx 1 root root       7 Dec 17 13:28 mysql-clone-v16da9ef36265f874.000001dd.74bf6687-lun-0-part1 -> ../dm-3