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.

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.

fosstechi

Recent Posts

How to List or Display all Cron Jobs in Linux

Cron is a command-line job scheduler available on Linux operating systems that allows users to…

1 year ago

How to Disable IPv6 on RHEL System

In computing, there are two types of IP addresses, IPv4 and IPv6. By default, IPv6…

1 year ago

How to View Contents of tar.gz File in Linux

A tarball is commonly known as a TAR file, short for tape archive, which is…

1 year ago

How to Create tar.gz File in Linux

A tar archive is a file that stores a collection of directories and files, also…

1 year ago

How to List Available Package Updates in Ubuntu

Keeping your Ubuntu system up-to-date is critical to ensuring a system's stability and security. This…

1 year ago

How to Check if Your Linux System Uses UEFI or BIOS

When you boot a Linux system, it boots into legacy BIOS (Basic Input/Output System) mode…

1 year ago

This website uses cookies.