As promised in the earlier post, for completeness sake, here’s the counterpart for removing the LUNs in the first place.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ; html-script: false ] #!/bin/bash KEY_FILE="/root/.ssh/netapp.dsa" SSH_OPTS="/root/.ssh/netapp-ssh_config" if [ $# -ne 2 ] ; then  echo "fas-remove-lunmap: FAS_CONTROLLER TARGET_IGROUP"  echo  echo "Remove every mapped lun from the target igroup (for example reinstallation)"  echo  echo "  Usage:"  echo "    - FAS_CONTROLLER:   Hostname/IP-adress of the DATA ONTAP controller"  echo "    - TARGET_IGROUP:    igroup that is actually modified"  echo  exit 1 fi FAS_CTRL=$1 TARGET=$2 ssh_fas() {  # $@: commands for Data ONTAP  COMMANDS="$@"  /usr/bin/ssh -i $KEY_FILE -l root -F $SSH_OPTS $COMMANDS } # Get the hostname of the controller, necessary for the reporting CTRL_HOSTNAME="$( ssh_fas $FAS_CTRL rdfile /etc/rc | grep ^hostname | cut -d  -f2 | tr 'a-z' 'A-Z' )" #set -x # Get the lun list.  for lun in $( ssh_fas $FAS_CTRL lun show -g $SOURCE | awk '{ print $1 }' | sort -u ); do   # If the LUN id is 0, skip otherwise we would remove the boot LUN   if [ "$LUN_ID" != "0" ] ; then     # Actually remove the mapping to our host     echo "Removing $lun from $TARGET"     ssh_fas $FAS_CTRL lun unmap $lun $TARGET   fi done #set +x | 
With that, you can simply run it against a NetApp controller and remove every LUN map except the one with LUN ID 0 (which is pretty handy when installing/reinstalling ESX servers).