sources/tech/20230816 How to find SAN LUN Mapped to VxVM Disk in Linux.md
4.7 KiB
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:
- How to Find SAN disk LUN id in Linux
- How to map ASM disks to Physical disks in Linux
- How to map SAN LUN, Disk and FileSystem in Linux
- How to map LUN, Disk, LVM and File System in Linux
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.
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.
via: https://www.2daygeek.com/find-san-lun-mapping-with-vxvm-disk-veritas-linux/
作者:Prakash Subramanian 选题:lujun9972 译者:译者ID 校对:校对者ID