When you are working in a storage environment, it is often desirable to add, remove or re-size storage devices. Once storage is allocated we need to scan and verify allocated storage SAN disk.
In this article, I will show commands to check/identify the attached LUN information in a Linux system.
What is a LUN
A LUN is a Logical Unit Number. It can be used to refer to an entire physical disk, or a subset of a larger physical disk or disk volume. The physical disk or disk volume could be an entire single disk drive, a partition (subset) of a single disk drive, or disk volume from a RAID controller comprising multiple disk drives aggregated together for larger capacity and redundancy.
1) Check attached LUN or SAN disk in Linux
To check the attached LUN from a storage device in Linux, we can use the /proc/scsi/scsi
file content but it will give you some information and you can not be able to distinguish physical attached drive to LUN. Display the content as below as below
# cat /proc/scsi/scsi Attached devices: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: VMware, Model: VMware Virtual S Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi0 Channel: 00 Id: 01 Lun: 00 Vendor: VMware, Model: VMware Virtual S Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi0 Channel: 00 Id: 02 Lun: 00 Vendor: VMware, Model: VMware Virtual S Rev: 1.0 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 00 Lun: 00 Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00 Type: CD-ROM ANSI SCSI revision: 05 Host: scsi3 Channel: 00 Id: 00 Lun: 00 Vendor: LIO-ORG Model: block Rev: 4.0 Type: Direct-Access ANSI SCSI revision: 05 Host: scsi3 Channel: 00 Id: 00 Lun: 01 Vendor: LIO-ORG Model: block2 Rev: 4.0 Type: Direct-Access ANSI SCSI revision: 05 Host: scsi3 Channel: 00 Id: 00 Lun: 02 Vendor: LIO-ORG Model: rhelblock Rev: 4.0 Type: Direct-Access ANSI SCSI revision: 05
Normally Luns would be showing as Host: scsi3 Channel: 00 Id: 00 Lun: 00
Below is another example of the same file where it's using a different storage vendor.
# cat /proc/scsi/scsi
Attached devices: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: HP 36.4G Model: MAN3367MC Rev: HP05 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 00 Lun: 00 Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003 Type: Unknown ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 00 Lun: 02 Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 00 Lun: 03 Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 01 Lun: 00 Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003 Type: Unknown ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 01 Lun: 02 Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003 Type: Direct-Access ANSI SCSI revision: 02 Host: scsi2 Channel: 00 Id: 01 Lun: 03 Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003
You can use iscsiadm (only used when storage using iscsi target) command to get information about attached lun.
# iscsiadm -m session -P 3 iSCSI Transport Class version 2.0-870 version 6.2.0.873-35 Target: iqn.2017-06.com.linoxide:target1 (non-flash) Current Portal: 172.16.20.139:3260,1 Persistent Portal: 172.16.20.139:3260,1 ********** Interface: ********** ............ ............ ************************ Attached SCSI devices: ************************ Host Number: 3 State: running scsi3 Channel 00 Id 0 Lun: 0 Attached scsi disk sdd State: running scsi3 Channel 00 Id 0 Lun: 1 Attached scsi disk sde State: running scsi3 Channel 00 Id 0 Lun: 2 Attached scsi disk sdf State: running
You can also check below path for lun information.
# ls /dev/disk/by-path/ ip-172.16.20.139:3260-iscsi-iqn.2017-06.com.linoxide:target1-lun-0 ip-172.16.20.139:3260-iscsi-iqn.2017-06.com.linoxide:target1-lun-1 ip-172.16.20.139:3260-iscsi-iqn.2017-06.com.linoxide:target1-lun-2 pci-0000:00:07.1-ata-2.0 pci-0000:00:10.0-scsi-0:0:0:0 pci-0000:00:10.0-scsi-0:0:0:0-part1 pci-0000:00:10.0-scsi-0:0:0:0-part2 pci-0000:00:10.0-scsi-0:0:1:0 pci-0000:00:10.0-scsi-0:0:2:0
Also, try using dmesg command
# dmesg | grep -i "attached " Attached scsi disk sda at scsi0, channel 0, id 0, lun 0 Attached scsi disk sdb at scsi2, channel 0, id 0, lun 2 Attached scsi disk sdc at scsi2, channel 0, id 0, lun 3 Attached scsi disk sdd at scsi2, channel 0, id 1, lun 2
2) Using multipath command
Redhat default multipathing service is multipathd daemon. Below commands are from a server that has a multipathing enabled using multipathd daemon and from its output you can check OS identified Lun information.
# multipath -v4 -ll Jun 21 04:58:40 | loading /lib64/multipath/libcheckdirectio.so checker Jun 21 04:58:40 | loading /lib64/multipath/libprioconst.so prioritizer Jun 21 04:58:40 | Discover device /sys/devices/pci0000:00/0000:00:07.1/ata2/host2/target2:0:0/2:0:0:0/block/sr0 Jun 21 04:58:40 | sr0: device node name blacklisted Jun 21 04:58:40 | Discover device /sys/devices/pci0000:00/0000:00:10.0/host0/target0:0:0/0:0:0:0/block/sda ................................ ................................ ===== paths list ===== uuid hcil dev dev_t pri dm_st chk_st vend/prod/rev dev_st 0:0:0:0 sda 8:0 -1 undef ready VMware, ,VMware Virtual S running 0:0:1:0 sdb 8:16 -1 undef ready VMware, ,VMware Virtual S running 0:0:2:0 sdc 8:32 -1 undef ready VMware, ,VMware Virtual S running 3:0:0:0 sdd 8:48 -1 undef ready LIO-ORG ,block running 3:0:0:1 sde 8:64 -1 undef ready LIO-ORG ,block2 running 3:0:0:2 sdf 8:80 -1 undef ready LIO-ORG ,rhelblock running Jun 21 04:58:40 | directio checker refcount 6 Jun 21 04:58:40 | directio checker refcount 5 Jun 21 04:58:40 | directio checker refcount 4 Jun 21 04:58:40 | directio checker refcount 3 Jun 21 04:58:40 | directio checker refcount 2 Jun 21 04:58:40 | directio checker refcount 1 Jun 21 04:58:40 | unloading const prioritizer Jun 21 04:58:40 | unloading directio checker
Hope this article helped you to gather lun information on your Linux operating system. Please provide your comments and suggestion on the below section.