Detect and Scan New LUNs on Linux
If LUN are not visible:
PURPOSE: All documents are provided on this Blog just for educational purposes only. Please make sure that you run it in your test environment before to move on to production environment.
Identify existing LUNs
cat /proc/scsi/scsi | egrep -i 'Host:' | wc -l
ll /dev/|grep oracle|wc -l
You can use the following command to have better output of all the disks
fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-|type|identifier'
or
fdisk -l | grep sd
ls -l /dev/disk/by-path/
ls -l /dev/disk/by-id/scsi*
ls -l /dev/disk/by-id/scsi*|wc -l
ls -l /dev/disk/by-uuid/ <<== find the correct SCSI device
Find host bus number.
ls /sys/class/scsi_host
or
To find which host bus number is relevant.
grep mpt /sys/class/scsi_host/host?/proc_name
/sys/class/scsi_host/host1/proc_name:mptspi <<== host1 is relevant and need to scan
Then you will scan every iscsi disk found and scan after every scanning if the new disk was detected. It means
scan each scsi host device
echo "- - -" > /sys/class/scsi_host/host1/scan
or
If you have too many hosts (from host0 to host20 for example), you can use the command below
# for host in `ls /sys/class/scsi_host/`;do
echo "- - -" >/sys/class/scsi_host/${host}/scan;
ls -l /dev/disk/by-id/scsi*|wc -l
To detect the LUN need to execute following command.
echo 1 > /sys/class/scsi_device/0\:0\:2\:0/device/rescan # put correct scsi id in this is 2
Or this command
rescan-scsi-bus.sh -a -w -m
--
Scan lun with multipath
vi /etc/multipath.conf
# LUNS Entry
multipaths {
multipath {
wwid 360050768018e02976000000000000v72
alias TST_map_LUN_01
}
}
multipath -l
/usr/bin/rescan-scsi-bus.sh -a -w -m
/usr/bin/rescan-scsi-bus.sh -a -w -r # for deleting LUNs that no longer exist
service multipathd restart
multipath -ll
mount Filesystem:
cd /dev/mapper/
ll
mkfs.xfs /dev/mapper/TST_map_LUN_01
Edit the entrty in /etc/fstab
/dev/mapper/TST_map_LUN_01 /data xfs defaults 0 0
mount -a