How to find SAN LUN Mapped to VxVM Disk in Linux

We’ve written several articles in the past to find LUN ID mapped to Block device/disk, but when you’re managing a VCS cluster there are some situations where you might want to map a LUN ID against a VxVM (Veritas Volume Manager ) disk for VxFS file system expansion.

This short article describes how to find the LUN number associated with a VxVM disk in Linux

Recommended Read:

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

This handy shell script helps you to identify which storage LUN associated to which VxVM disk on Linux.

How this script works

This script follow the below steps to collect and print these information’s.

  • It collects the list of active ‘Disk Group’ (DG) on the system
  • Find the ‘Device Names’ associated with the respective DGs.
  • Next, it lists the ‘Block Devices’ mapped with the respective devices.
  • Finally collects the LUN IDs associated with these block devices and prints them all together like DG name, block device name and LUN numbers.
vi VxVM_disk_mapping_with_LUN_number.sh

#!/bin/bash
###########################################################
# Purpose: Mapping LUN Number to VxVM Disk in Linux
# Author: 2DayGeek
# 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 d_name in `vxdisk -e list | grep -i $dg_name | awk '{print $1}'
  do 
    for b_device in `vxdisk list $d_name | grep -w state=enabled | awk '{print $1}' | head -1`
    do
     echo "$dg_name --> $b_device --> $(lsscsi --scsi | grep $b_device | awk '{print $NF}'"
    done
  done
done | column -t

Set an executable permission to shell script file.

chmod +x VxVM_disk_mapping_with_LUN_number.sh

Finally execute the script to view the results.

sh VxVM_disk_mapping_with_LUN_number.sh

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

Mapping SAN LUN and associated VxVM disks on Linux

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

# for dg_name in `vxdg list | awk '{print $1}' | grep -v NAME`; do for d_name in `vxdisk -e list | grep -i $dg_name | awk '{print $1}'; do for b_device in `vxdisk list $d_name | grep -w state=enabled | awk '{print $1}' | head -1`; do echo "$dg_name --> $b_device --> $(lsscsi --scsi | grep $b_device | awk '{print $NF}'"; done; done; done | column -t

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

Wrapping Up

In this tutorial, we have shown you how to find the LUN number mapped with VxVM (Veritas Volume Manager) disk in Linux.

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

About Prakash Subramanian

Prakash Subramanian is a Linux lover and has 3.5+ years of experience in linux server administration with major Linux distribution such as (RHEL, CentOS, Ubuntu). He is currently working as a Senior L2 Linux Server administrator.

View all posts by Prakash Subramanian

Leave a Reply

Your email address will not be published. Required fields are marked *