When using ASMLIB to manage ASM disks, the device path info is not displayed in gv$asm_disk.path.
If you are using ASMLIB Support Tools 2.1. and later (package oracleasm-support-2.1*) you can get that info by running 'oracleasm querydisk -p' as root:
# ls -l /dev/oracleasm/disks
total 0
brw-rw---- 1 grid asmadmin 8, 5 May 2 12:00 DISK1
brw-rw---- 1 grid asmadmin 8, 6 May 2 12:00 DISK2
brw-rw---- 1 grid asmadmin 8, 7 May 2 12:00 DISK3
...
# oracleasm querydisk -p DISK1
Disk "DISK1" is a valid ASM disk
/dev/sda5: LABEL="DISK1" TYPE="oracleasm"
total 0
brw-rw---- 1 grid asmadmin 8, 5 May 2 12:00 DISK1
brw-rw---- 1 grid asmadmin 8, 6 May 2 12:00 DISK2
brw-rw---- 1 grid asmadmin 8, 7 May 2 12:00 DISK3
...
# oracleasm querydisk -p DISK1
Disk "DISK1" is a valid ASM disk
/dev/sda5: LABEL="DISK1" TYPE="oracleasm"
Otherwise, that info can be obtained with a shell script like this:
#!/bin/bash
for asmlibdisk in `ls /dev/oracleasm/disks/*`
do
echo "ASMLIB disk name: $asmlibdisk"
asmdisk=`kfed read $asmlibdisk | grep dskname | tr -s ' '| cut -f2 -d' '`
echo "ASM disk name: $asmdisk"
majorminor=`ls -l $asmlibdisk | tr -s ' ' | cut -f5,6 -d' '`
device=`ls -l /dev | tr -s ' ' | grep "$majorminor" | cut -f10 -d' '`
echo "Device path: /dev/$device"
done
for asmlibdisk in `ls /dev/oracleasm/disks/*`
do
echo "ASMLIB disk name: $asmlibdisk"
asmdisk=`kfed read $asmlibdisk | grep dskname | tr -s ' '| cut -f2 -d' '`
echo "ASM disk name: $asmdisk"
majorminor=`ls -l $asmlibdisk | tr -s ' ' | cut -f5,6 -d' '`
device=`ls -l /dev | tr -s ' ' | grep "$majorminor" | cut -f10 -d' '`
echo "Device path: /dev/$device"
done
The script can be run as OS user that owns ASM or Grid Infrastructure home, i.e. it does not need to be run as privileged user. The only requirement it that kfed binary exists and that it is in the PATH.
If an ASMLIB disk was alrady deleted, it will not show up in /dev/oracleasm/disks. I can check for devices that are (or were) associated with ASM with a script like this:
#!/bin/bash
for device in `ls /dev/sd*`
do
asmdisk=`kfed read $device|grep ORCL|tr -s ' '|cut -f2 -d' '|cut -c1-4`
if [ "$asmdisk" = "ORCL" ]
then
echo "Disk device $device may be an ASM disk"
fi
done
for device in `ls /dev/sd*`
do
asmdisk=`kfed read $device|grep ORCL|tr -s ' '|cut -f2 -d' '|cut -c1-4`
if [ "$asmdisk" = "ORCL" ]
then
echo "Disk device $device may be an ASM disk"
fi
done
This scripts takes a peek at sd devices in /dev, so in addition to kfed in the PATH, it needs to be run as privileged user. Of course you can look at /dev/dm*, /dev/mapper, etc or all devices in /dev, although that may not be a good idea.
There was recently a question on how to achieve the above without kfed. Here is one way to do it:
#!/bin/bash
for device in `ls /dev/sd*`
do
asmdisk=`od -c $device | head | grep 0000040 | tr -d ' ' | cut -c8-11`
if [ "$asmdisk" = "ORCL" ]
then
echo "Disk device $device may be an ASM disk"
fi
done
for device in `ls /dev/sd*`
do
asmdisk=`od -c $device | head | grep 0000040 | tr -d ' ' | cut -c8-11`
if [ "$asmdisk" = "ORCL" ]
then
echo "Disk device $device may be an ASM disk"
fi
done
Great information.. Keep it up.
ReplyDeleteI really like this wee script for showing mapping:
ReplyDelete/etc/init.d/oracleasm querydisk -d `/etc/init.d/oracleasm listdisks -d` |
cut -f2,10,11 -d" " | perl -pe 's/"(.*)".*\[(.*), *(.*)\]/$1 $2 $3/g;' |
while read v_asmdisk v_minor v_major
do
v_device=`ls -la /dev | grep " $v_minor, *$v_major " | awk '{print $10}'`
echo "ASM disk $v_asmdisk based on /dev/$v_device [$v_minor, $v_major]"
done
From Ronny Egner's blog
http://blog.ronnyegner-consulting.de/2009/10/07/useful-asm-scripts-and-queries/
He found it somewhere on the web and updated for modern ASM versions.
Output looks like:
ASM disk ORA_FPF_12GB_EMCP004 based on /dev/emcpowera1 [120, 1]
ASM disk ORA_FPF_12GB_EMCP005 based on /dev/emcpowerb1 [120, 17]
ASM disk ORA_FPF_12GB_EMCP006 based on /dev/emcpoweraf1 [120, 497]
ASM disk ORA_FPF_12GB_EMCP007 based on /dev/emcpoweras1 [120, 705]
...
Yes, not bad.
ReplyDeleteThis is what I was looking for. Thanks!
ReplyDeleteGlad to see that someone finds this useful :)
Delete