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. Let’s 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.


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

Set an executable permission to ‘’ file.

chmod +x

Finally run the script to view the results.

Mapping SAN LUN to Physical Disk and FileSystem in Linux

Make a Note: In the above output, device sda won’t show any LUN info because it’s a virtual disk added from VMWare end, which doesn’t have any LUN. Other 3 disks are mapped from Storage that’s 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, we’ve 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.

Leave a Reply

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