how to find SAN Disk LUN id in Linux Identify SAN LUN underlying OS disk
Most of the times when your dealing with SAN attached disks, some times you would like to increase / decrease LUN space by decreasing / Increasing LUN size you should definitely know which LUN is assigned to which OS Underlying disk. Identify SAN LUN underlying OS disk is not straight forward we have to match few outputs together to identify them. Let’s see how to find SAN Disk LUN id in Linux.
After attaching the storage LUN’s to Linux you have to scan to display as attached disks. Use below command to scan for new SAN LUN’s, Required Super User privileges to run command. Identify SAN LUN underlying OS Disk
[root@TechTutorials~]# ls /sys/class/scsi_host/ | while read host ; do echo "- - -" > /sys/class/scsi_host/$host/scan ; done
After that you can use fdisk -l command display the attached disks Identify SAN LUN underlying OS Disk
[root@Techtutorials ~]#sudo /sbin/fdisk -l Disk /dev/sde: 236.2 GB, 236223201280 bytes 255 heads, 63 sectors/track, 28719 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sde doesn't contain a valid partition table
how to find SAN Disk LUN id in Linux
Use below command to see all attached disks are SAN disks are local disks Identify SAN LUN underlying OS Disk
[root@Techtutorials ~]# cat /proc/scsi/scsi Host: scsi7 Channel: 00 Id: 01 Lun: 00 Vendor: DGC Model: LUNZ Rev: 0532 Type: Direct-Access ANSI SCSI revision: 04 Host: scsi8 Channel: 00 Id: 00 Lun: 01 Vendor: NETAPP Model: LUN C-Mode Rev: 8300 Type: Direct-Access ANSI SCSI revision: 05
By reading above output of the command we can identify that scsi8 channel is NetApp SAN disk and it’s LUN id is 01.
[root@TechTutorials ~]# ls -ld /sys/block/sd*/device lrwxrwxrwx 1 root root 0 Nov 13 23:29 /sys/block/sdd/device -> ../../devices/pci0000:00/0000:00:03.0/0000:04:00.0/host7/rport-7:0-3/target7:0:3/7:0:3:1 lrwxrwxrwx 1 root root 0 Nov 16 03:00 /sys/block/sde/device -> ../../devices/pci0000:40/0000:40:03.0/0000:42:00.0/host8/rport-8:0-0/target8:0:0/8:0:0:1
Highlighted output is showing that scsi channel id is 8 and LUN id is 1, Like wise we can identify the associated disk name /dev/sde and its LUN id. Collect LUN id and path details go to SAN console and match with LUN id. Find SAN Disk Lun id
[root@TechTutorials]ls -la /dev/disk/by-id/ total 0 lrwxrwxrwx 1 root root 9 Nov 16 2015 scsi-3600a09803830357a2f5d47686838662d -> ../../sdg lrwxrwxrwx 1 root root 10 Nov 16 2015 scsi-3600a09803830357a2f5d47686838662d-part1 -> ../../sdg1
Identify SAN LUN underlying OS disk
Second method to identify the Underlying OS disk, for these below commands we have to install sg3 utilities. Before installing sg3 utils below commands will not work.
[root@Techtutorials ~]#yum install sg3_utils
[root@Techtutorials ~]#sg_scan -i /dev/sg7: scsi7 channel=0 id=4 lun=1 NETAPP LUN C-Mode 8300 [rmb=0 cmdq=1 pqual=0 pdev=0x0] /dev/sg8: scsi8 channel=0 id=3 lun=0 DGC LUNZ 0532 [rmb=0 cmdq=1 pqual=0 pdev=0x0]
sg_map -x command will map your OS disk with SAN mapped disk so that we can easily identify them, it will also give Channel id, LUN id, associated disk and so an.
[root@Techtutorials ~]#sg_map -x /dev/sg5 8 0 0 1 0 /dev/sde /dev/sg6 8 0 1 1 0 /dev/sdf
-sd option along with sg_map will provide you straight forward OS disk mapping with SAN LUN
[root@Techtutorials ~]#sg_map -sd /dev/sg5 /dev/sde /dev/sg6 /dev/sdf
More options of sg_map command
- -a assume the sg devices have alphabetical device names and loop through /dev/sga, /dev/sgb, etc. Default is numeric scan. Note
that sg device nodes with an alphabetical index have been deprecated since the linux kernel 2.2 series.
- -h print usage message then exit.
- -i in addition do a standard INQUIRY and output vendor, product and revision strings for devices that are found.
- -n assume the sg devices have numeric device names and loop through /dev/sg0, /dev/sg1, etc. Default is numeric scan
- -scd display mappings to SCSI cdrom device names of the form /dev/scd0, /dev/scd1 etc
- -sd display mappings to SCSI disk device names
- -sr display mappings to SCSI cdrom device names of the form /dev/sr0, /dev/sr1 etc
- -st display mappings to SCSI tape device names Find SAN Disk Lun id
- -V print out version string then exit (without further ado).
- -x after each active sg device name is displayed there are five digits: <host_number> <bus> <scsi_id> <lun> <scsi_type>
Conclusion: There are many ways to identify but above are easy ways to identify Underlying OS disk. Find SAN Disk Lun id
Thanks for your wonderful Support and Encouragement