I've added it. # Returns the list of existing targets per host idlist () { local tmpid local newid local oldid oldlist=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*:[0-9]*\)/\1/p" | uniq) # Rescan LUN 0 to check if we found new targets echo "${channel} - -" > /sys/class/scsi_host/host${host}/scan udevadm_settle newlist=$(ls /sys/class/scsi_device/ | sed -n "s/${host}:${channel}:\([0-9]*:[0-9]*\)/\1/p" | uniq) It did not help though.