TranslateProject/sources/tech/20230816 How to find SAN LUN Mapped to VxVM Disk in Linux.md
DarkSun 2d662574d5 选题[tech]: 20230816 How to find SAN LUN Mapped to VxVM Disk in Linux
sources/tech/20230816 How to find SAN LUN Mapped to VxVM Disk in Linux.md
2023-08-16 12:16:50 +08:00

4.7 KiB
Raw Blame History

How to find SAN LUN Mapped to VxVM Disk in Linux

Weve written several articles in the past to find LUN ID mapped to Block device/disk, but when youre 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 informations.

  • 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

本文由 LCTT 原创编译,Linux中国 荣誉推出