TranslateProject/sources/tech/20230816 How to map SAN LUN, Disk and FileSystem in Linux.md
DarkSun 5ef67f0f17 选题[tech]: 20230816 How to map SAN LUN, Disk and FileSystem in Linux
sources/tech/20230816 How to map SAN LUN, Disk and FileSystem in Linux.md
2023-08-16 12:18:26 +08:00

3.6 KiB
Raw Blame History

How to map SAN LUN, Disk and FileSystem in Linux

For some requirements, you may need to find a block device mapped against a logical unit number (LUNs) and filesystem (FS) for FS expansion or disaster recovery (DR) activity.

Similar activity may happens frequently when you are managing the bigger infrastructure. Lets say, more than 1000+ servers hosting various applications.

Refer the following articles similar to this:

In this article, we will show you how to map physical disk, Storage LUN and FileSystem (FS) in Linux.

Shell Script to map Physical disks to Storage LUNs and FileSystem in Linux

This small shell script helps you to identify which SAN disks are mapped to which Block devices and Filesystem on Linux.


    vi block_device_mapping_with_LUN_FS.sh

    #!/bin/bash
    for lunmap in `lsblk | grep disk | grep ^s | awk '{print $1}'`
    do
    for mpoint in `lsblk /dev/$lunmpa | grep lvm | awk '{print $NF}'`
    do
    echo "$lunmap --> $mpoint --> $(smartctl -a /dev/$lunmap | grep "Logical Unit id" | awk -F":" '{print $2}')"
    done
    done

Set an executable permission to block_device_mapping_with_LUN_FS.sh file.


    chmod +x block_device_mapping_with_LUN_FS.sh

Finally run the script to view the results.


    sh block_device_mapping_with_LUN_FS.sh

Make a Note: In the above output, device sda wont show any LUN info because its a virtual disk added from VMWare end, which doesnt have any LUN. Other 3 disks are mapped from Storage thats why we are able to see LUN info.

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


    for lunmap in `lsblk | grep disk | grep ^s | awk '{print $1}'`; do for mpoint in `lsblk /dev/$lunmpa | grep lvm | awk '{print $NF}'`; do echo "$lunmap --> $mpoint --> $(smartctl -a /dev/$lunmap | grep "Logical Unit id" | awk -F":" '{print $2}')"; done; done

    sda --> /
    sda --> /usr
    sda --> /opt
    sda --> /tmp
    sda --> /var
    sda --> /home
    sdb --> /data -->      0x3600d0230000000000e1140463955737c
    sdc --> /app -->      0x3600d0230000000000e114046395577cd
    sdd --> /backup -->      0x3600d0230000000000e11404639558cc5

Wrapping Up

In this tutorial, weve shown you how to check LUN presented from SAN with underlying OS disk and associated Filesystem on Linux.

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


via: https://www.2daygeek.com/map-san-lun-physical-disk-filesystem-linux/

作者:Rasool Cool 选题:lujun9972 译者:译者ID 校对:校对者ID

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