In some cases, you may need to find a block device mapped against an ASM disks and logical unit number (LUNs) for ASM disk addition or disaster recovery (DR) activity.
There are multiple ways to check this information. However, you will be getting half of the information when you use all those commands.
It doesn’t show you all required information such as ASM disks, Block Devices and LUN IDs in a single output. You may need to write a small shell script to gather all information’s.
In this tutorial, we will show you how to check disk mapping between ASM disk, Physical disk and Storage LUNs in Linux.
Go to the following link to see how to manage Oracle ASM disks in Linux such as start, enable, stop, list, query and etc,.
To list all ASM disks, run:
ls -lh /dev/oracleasm/disks total 0 brw-rw---- 1 grid oinstall 65, 33 Apr 12 18:43 2GPROD_DATA01 brw-rw---- 1 grid oinstall 8, 225 Apr 12 18:43 2GPROD_DATA02 brw-rw---- 1 grid oinstall 8, 161 Apr 12 18:43 2GPROD_DATA03 brw-rw---- 1 grid oinstall 8, 177 Apr 12 18:43 2GPROD_DATA04 brw-rw---- 1 grid oinstall 8, 241 Apr 12 18:43 2GPROD_DATA05 brw-rw---- 1 grid oinstall 8, 193 Apr 12 18:43 2GPROD_DATA06 brw-rw---- 1 grid oinstall 8, 49 Apr 12 18:43 2GPROD_DATA07
In the above output, after group name (oinstall) refer to Major/Minor number, which can be used to match the physical devices in Linux system as shown below:
Eg: for 2GPROD_DATA01 major=65
and minor=33
cat /proc/partitions | (IFS= read -r header; echo $header; grep -w 33;) major minor #blocks name 65 33 4008217 sdbi1
Method-1 : Shell Script to map ASM disks to Block devices and Storage LUNs in Linux
To map ASM disks against block devices & LUNs, use the following shell script. This script will work in Virtual Machine (VMs) and Physical Machine.
vi asm_disk_mapping.sh #!/bin/bash for ASM_DISK in `ls /dev/oracleasm/disks` do MINOR=$(ls -l /dev/oracleasm/disks|grep $ASM_DISK | awk '{print $6}') MAJOR=$(ls -l /dev/oracleasm/disks|grep $ASM_DISK | awk '{print $5}' | cut -d"," -f1) PHY_DISK=$(ls -l /dev/* | grep ^b | grep "$MAJOR, *$MINOR" | awk '{print $NF}'|tr -d [:digit:]) LUN_ID=$(lsscsi --scsi | grep $PHY_DISK| awk '{print $NF}') echo "$ASM_DISK: $PHY_DISK --> $LUN_ID" done
Set an executable permission to ‘asm_disk_mapping.sh’ file.
chmod +x asm_disk_mapping.sh
Finally run the script to view the mapped device information. The following output shows a list of actual block devices, which are mapped to ASM disks in Linux.
sh asm_disk_mapping.sh
Method-2 : Shell Script to map ASM Disks to Physical Disk Devices and SAN LUNs
Alternatively, you can use the following script if you don’t want to try with the above one. This will show all paths if it’s a physical server as it would use multipathing.
vi asm_disk_mapping_1.sh #!/bin/bash for ASM_DISK in `ls /dev/oracleasm/disks` do for BDEV_NAME in `blkid | grep -w sd.*oracleasm | grep -i $ASM_DISK | cut -d':' -f1|tr -d [:digit:]|tr -d [:]|cut -d"/" -f3` do LUN_ID=$(lsscsi --scsi | grep $BDEV_NAME| awk '{print $NF}') echo "$ASM_DISK: $BDEV_NAME --> $LUN_ID" done done
Set an executable permission to ‘asm_disk_mapping_1.sh’ file.
chmod +x asm_disk_mapping_1.sh
Finally run the script to see the mapped devices information.
sh asm_disk_mapping_1.sh 2GPROD_DATA01: sdi --> 3600d0230000000000e1140463955737c 2GPROD_DATA02: sdj --> 3600d0230000000000e114046395577cd 2GPROD_DATA03: sdk --> 3600d0230000000000e11404639558cc5 2GPROD_DATA04: sdl --> 3600d0230000000000e11404639558cd3 2GPROD_DATA05: sdm --> 3600d0230000000000e11404639558ce4 2GPROD_DATA06: sdn --> 3600d0230000000000e11404639558cf5 2GPROD_DATA07: sdo --> 3600d0230000000000e11404639558cg6
How to list Oracle ASM disks against Major and Minor number
If you would like to check Oracle ASM disks mapping against major and minor number using oracleasm command, execute the below command.
for ASMdisk in `oracleasm listdisks`; do oracleasm querydisk -d $ASMdisk; done Disk "2GPROD_DATA01" is a valid Disk on device [65, 33] Disk "2GPROD_DATA02" is a valid Disk on device [8, 225] Disk "2GPROD_DATA03" is a valid Disk on device [8, 161] Disk "2GPROD_DATA04" is a valid Disk on device [8, 177] Disk "2GPROD_DATA05" is a valid Disk on device [8, 241] Disk "2GPROD_DATA06" is a valid Disk on device [8, 193] Disk "2GPROD_DATA07" is a valid Disk on device [8, 49]
Wrapping Up
In this tutorial, we’ve shown you how to map Oracle ASM disks against to Physical disks & Storage LUNs in Linux
If you have any questions or feedback, feel free to comment below.