May 11, 2024

How to Identify LUN Mapped to VxVM Disk in Linux

On Linux, you can quickly find out how LUNs are mapped to the underlying OS disk using the lsscsi command. If you want to identify the correct mapping information for LVM (Logical Volume Manager), VCS cluster, GPFS cluster, etc., you may need to write a small shell script based on your requirement.

For instance, if you are managing a Veritas Cluster Server (VCS) on Linux and want to find a list of LUNs mapped to a VxVM (Veritas Volume Manager) disk for Veritas File System (VxFS) expansion, read this article.

This short article describes how to find which LUN number associated with which Disk Group (DG), and VxVM disk in Linux.

Shell Script to find LUN Number Mapped to VxVM Disk in Linux

This simple shell script allows you to identify/match a list of LUN associated with a VxVM disk & Veritas disk group on Linux.

vi LUN_mapping_with_VxVM_disk.sh

#!/bin/bash
###########################################################
# Purpose: Mapping LUN Number to VxVM Disk in Linux
# Author: FossTechi
# Version: v1.0
###########################################################

echo "DG_Name		Block_Device		LUN_Number"
echo "-------------------------------------------------------------------"
for dg_name in `vxdg list | awk '{print $1}' | grep -v NAME`
do
 for b_device in `vxdisk -e list | grep -i $dg_name | awk '{print $7}'`
    do
     echo "$dg_name --> $b_device --> $(lsscsi --scsi | grep $b_device | awk '{print $NF}'"
    done
done | column -t

Set an executable permission to shell script file.

chmod +x LUN_mapping_with_VxVM_disk.sh

Finally execute the script to view the results.

sh LUN_mapping_with_VxVM_disk.sh

Your output will resemble this. However, the DG name, Block devices and LUN would differ from this.

LUN mapping with VxVM disk in Linux

If you would like to run the above script on the fly, use the following one liner script.

# (echo "DG_Name Block_Device LUN_Number"; for dg_name in `vxdg list | awk '{print $1}' | grep -v NAME`; do for b_device in `vxdisk -e list | grep -i $dg_name | awk '{print $7}'`; do echo "$dg_name --> $b_device --> $(lsscsi --scsi | grep $b_device | awk '{print $NF}'"; done; done) | column -t

DG_Name         Block_Device LUN_Number
apachedg   -->  sde 	-->  3600d0230000000000e11404639558823
apachedg   -->  sdf 	-->  3600d0230000000000e11404639558824
apachedg   -->  sdg 	-->  3600d0230000000000e11404639558825
sftpdg     -->  sdh 	-->  3600d0230000000000e11404639558826
sftpdg     -->  sdi 	-->  3600d0230000000000e11404639558827

Final Thoughts

In this article, we covered how to find the Storage LUN number mapped with VxVM (Veritas Volume Manager) disk & Veritas Disk Group (DG) in Linux.

If you have any questions or feedback, feel free to comment below.

Leave a Reply

%d bloggers like this: