How to Map ASM disk to physical device

Here I have used two script. You can use script in Example 2 to see the mapping with size.

Example 1:

[root@stage ~]#  /etc/init.d/oracleasm listdisks

DATA1

DATA2

DATA3

DATA4

DATA5

INDX1

INDX2

INDX3

[root@stage ~]#  /etc/init.d/oracleasm querydisk -d DATA1

Disk "DATA1" is a valid ASM disk on device [8,17]

 

[root@stage ~]# ls -l /dev | grep 8, | grep 17

brw-rw---- 1 root disk      8,  17 Sep 12 15:00 sdb1


You can use below script to check the physical device for all the disk.

#!/bin/bash

for i in `/etc/init.d/oracleasm listdisks`
do
v_asmdisk=`/etc/init.d/oracleasm querydisk -d $i | awk  '{print $2}'`
v_minor=`/etc/init.d/oracleasm querydisk -d $i | awk -F[ '{print $2}'| awk -F] '{print $1}' | awk -F, '{print $1}'`
v_major=`/etc/init.d/oracleasm querydisk -d $i | awk -F[ '{print $2}'| awk -F] '{print $1}' | awk -F, '{print $2}'`
v_device=`ls -la /dev | grep $v_minor | grep $v_major | awk '{print $10}'`
echo "ASM disk $v_asmdisk based on /dev/$v_device  [$v_minor $v_major]"
done

 

Output will be look like this:

ASM disk "DATA1" based on /dev/sdb1  [8 17]

ASM disk "DATA2" based on /dev/sdc1  [8 33]

ASM disk "DATA3" based on /dev/sdd1  [8 49]

ASM disk "DATA4" based on /dev/sde1  [8 65]

ASM disk "DATA5" based on /dev/sdf1  [8 81]

ASM disk "INDX1" based on /dev/sdg1  [8 97]

ASM disk "INDX2" based on /dev/sdh1  [8 113]

ASM disk "INDX3" based on /dev/sdi1  [8 129]

Example 2:

Please Export your correct ORACLE_HOME directory in the script

asm_mapping.sh

printf "\n%-15s %-14s %-11s %-7s\n" "ASM disk" "based on" "Minor,Major" "Size (Mb)"
printf "%-15s %-14s %-11s %-7s\n" "===============" "=============" "===========" "========="
export ORACLE_HOME=/opt/oracle/product/11.2.0.3
for i in `/etc/init.d/oracleasm listdisks`
do
v_asmdisk=`/etc/init.d/oracleasm querydisk -d $i | awk '{print $2}'| sed 's/\"//g'`
v_minor=`/etc/init.d/oracleasm querydisk -d  $i | awk -F[ '{print $2}'| awk -F] '{print $1}' | awk -F,  '{print $1}'`
v_major=`/etc/init.d/oracleasm querydisk -d $i | awk -F[ '{print $2}'| awk -F] '{print $1}' | awk -F, '{print $2}'`
v_device=`ls -la /dev | awk -v v_minor="$v_minor," -v v_major=$v_major '{if ( $5==v_minor ) { if ( $6==v_major ) { print $10}}}'`
v_size=`${ORACLE_HOME}/bin/kfod asm_diskstring='ORCL:*' disks=all | grep ${v_asmdisk} | awk '{print $2}'`
Total_size=`expr $Total_size + $v_size`
Formated_size=`echo $v_size | sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta'`
printf "%-15s %-14s %-11s %-7s\n" $v_asmdisk "/dev/$v_device" "[$v_minor $v_major]" $Formated_size
done
Formated_Total_size=`echo $Total_size | sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta'`
printf "\nTotal: %43s\n\n" $Formated_Total_size

 

[root@stagedb]# ./asm_mapping.sh

ASM disk

based on

Minor,Major

Size(Mb)

DATA

/dev/sdb1

[8 17]

2,097,149

INDX

/dev/sdc1

[8 33]

2,097,149

REDO1

/dev/dm-9

[253 9]

204,800

Total:

 

 

4,399,098


Comments