November 3, 2024

How to Find SAN Disk LUN Number in Linux

When your dealing with SAN attached disks on Linux system, you may need to increase or release them for various reasons. In order to perform these operations, you must know which LUN is assigned to which OS Underlying disk.

Identify SAN LUN underlying OS disk is straight forward with lsscsi command on Linux. In this quick article, we will describe how to find all storage devices attached to a Linux system.

Finding SAN Disk LUN Number using lsscsi command in Linux

lsscsi stands for list small Computer System Interface, which uses information in sysfs to list SCSI devices (or hosts) currently attached to the Linux system.

Run the following lsscsi command to map the block device against the attached storage devices (SAN) on the Linux system.

According the below output. Device 'sda' is a virtual disk that was attached from VMWare and used for OS partition. Devices 'sdb to sdi' were mapped from the Storage array, which is why these are showing the LUN number against each block devices.

# lsscsi --scsi

[0:0:0:0]   disk    VMWare    Virtual disk     2.0    /dev/sda   -
[0:0:1:0]   disk    EMC       SYMMETRIX        6544   /dev/sdb   3600d0230000000000e11404639558820
[0:0:2:0]   disk    EMC       SYMMETRIX        6544   /dev/sdc   3600d0230000000000e11404639558821
[0:0:3:0]   disk    EMC       SYMMETRIX        6544   /dev/sdd   3600d0230000000000e11404639558822
[0:0:4:0]   disk    EMC       SYMMETRIX        6544   /dev/sde   3600d0230000000000e11404639558823
[1:0:0:0]   disk    EMC       SYMMETRIX        6544   /dev/sdf   3600d0230000000000e11404639558824
[1:0:1:0]   disk    EMC       SYMMETRIX        6544   /dev/sdg   3600d0230000000000e11404639558825
[1:0:2:0]   disk    EMC       SYMMETRIX        6544   /dev/sdh   3600d0230000000000e11404639558826
[1:0:3:0]   disk    EMC       SYMMETRIX        6544   /dev/sdi   3600d0230000000000e11404639558827
[3:0:0:0]   cd/dvd  NECVMWar  VMWare IDE CDR10 1.00   /dev/sr0   -

The above output consists of seven parts and the details are below:

Finding SAN Disk LUN Number in Linux

Details:

  • [0:0:1:0] –> The first column entry on each line is the scsi_host (00),channel (00),target_number (01), and LUN (00). It is placed in brackets and each element is colon separated (H:C:T:L – (Host:Bust:Target:LUN)).
  • disk –> SCSI peripheral type such as disk, CD-ROM, Direct-Access, etc,.
  • EMC –> Vendor Name
  • SYMMETRIX –> Model Name
  • 6544 –> Revision String
  • 3600d0230000000000e11404639558820 –> Storage LUN Number

To include Disk/LUN size with lsscsi command, run:

# lsscsi --scsi --size

[0:0:0:0]   disk    VMWare    Virtual disk     2.0    /dev/sda   -  70.2GB
[0:0:1:0]   disk    EMC       SYMMETRIX        6544   /dev/sdb   3600d0230000000000e11404639558820  5.36GB
[0:0:2:0]   disk    EMC       SYMMETRIX        6544   /dev/sdc   3600d0230000000000e11404639558821  10.7GB
[0:0:3:0]   disk    EMC       SYMMETRIX        6544   /dev/sdd   3600d0230000000000e11404639558822  10.7GB
[0:0:4:0]   disk    EMC       SYMMETRIX        6544   /dev/sde   3600d0230000000000e11404639558823  16.21GB
[1:0:0:0]   disk    EMC       SYMMETRIX        6544   /dev/sdf   3600d0230000000000e11404639558824  16.21GB
[1:0:1:0]   disk    EMC       SYMMETRIX        6544   /dev/sdg   3600d0230000000000e11404639558825  48.3GB
[1:0:2:0]   disk    EMC       SYMMETRIX        6544   /dev/sdh   3600d0230000000000e11404639558826  48.3GB
[1:0:3:0]   disk    EMC       SYMMETRIX        6544   /dev/sdi   3600d0230000000000e11404639558827  32.2GB
[3:0:0:0]   cd/dvd  NECVMWar  VMWare IDE CDR10 1.00   /dev/sr0   -  1.07GB

Checking SAN Disk LUN Number in Linux

We can identify the associated disk name and its LUN number by listing the information from the following path '/dev/disk/by-id/'. However, this output shows you a lot of information, so it can be very difficult to understand for the first time.

# ls -ltrh /dev/disk/by-id | egrep -i '^scsi|^wwn'

total 0
lrwxrwxrwx 1 root root   9 Jul 16  2023 scsi-3600d0230000000000e11404639558820 -> ../../sdb
lrwxrwxrwx 1 root root  10 Jul 16  2023 wwn-0x600d0230000000000e11404639558820-part1 -> ../../sdb1
lrwxrwxrwx 1 root root   9 Jul 16  2023 scsi-3600d0230000000000e11404639558821 -> ../../sdc
lrwxrwxrwx 1 root root  10 Jul 16  2023 wwn-0x600d0230000000000e11404639558821-part1 -> ../../sdc1
lrwxrwxrwx 1 root root   9 Jul 16  2023 scsi-3600d0230000000000e11404639558822 -> ../../sdd
lrwxrwxrwx 1 root root  10 Jul 16  2023 wwn-0x600d0230000000000e11404639558822-part1 -> ../../sdd1
lrwxrwxrwx 1 root root   9 Jul 16  2023 scsi-3600d0230000000000e11404639558823 -> ../../sde
lrwxrwxrwx 1 root root  10 Jul 16  2023 wwn-0x600d0230000000000e11404639558823-part1 -> ../../sde1
lrwxrwxrwx 1 root root   9 Jul 16  2023 scsi-3600d0230000000000e11404639558824 -> ../../sdf
lrwxrwxrwx 1 root root  10 Jul 16  2023 wwn-0x600d0230000000000e11404639558824-part1 -> ../../sdf1

Checking LUN information in Linux

You can view detailed information for a SAN LUN using the smartctl command in Linux. Smartctl (Self-Monitoring, Analysis and Reporting Technology) is a command line tool that perform SMART tasks such as monitor the reliability of the hard drive, predict drive failures and perform various types of drive self-test.

# smartctl -a /dev/sdb

smartctl 7.1 2020-04-05 r5049 [x86_64-linux-4.18.0-425.10.1.el8_7.x86_64] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor:		      EMC
Product:	      SYMMETRIX
Revision:	      6544
Compliance:           SPC-3
User Capacity:        5,368,709,120 bytes [5.00 GB]
Logical block size:   512 bytes
Rotation Rate:        Solid State Device
Logical Unit id:      0x3600d0230000000000e11404639558820
Serial Number:        36002345D00LP
Device type:	      disk
Transport protocol:   Fibre channel (FCP-2)
Local Time is:        Mon Jul 17 22:48:21 2023 IST
SMART support is:     Available - device has SMART capability.
SMART support is:     Enabled
Temperature Warning:  Disabled or Not Supported

=== START OF READ SMART DATA SECTION ===
SMART Health Status:  OK
Current Drive Temperature:    0 C
Drive Trip Temperature:       0 C

Elements in grown defect list: 0

Error Counter logging not supported

Device does not support Self Test logging

Conclusion

This article showed you how to use the lsscsi command to find all storage devices attached to a Linux system. Also, showed you how to view detailed information for a SAN LUN using the smartctl command in Linux.

If you have any questions or feedback, feel free to comment below. Kindly support us by sharing this article with wider circle.

One thought on “How to Find SAN Disk LUN Number in Linux

Leave a Reply

%d bloggers like this: