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:**
* **[How to Find SAN disk LUN id in Linux][1]**
* **[How to map ASM disks to Physical disks in Linux][2]**
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
```
![][3]
**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