List of Linux physical devices, mapped by ASM disks, using Major & minor number

 

In this article, I will explain how to find the physical Linux disks name for a given ASM disk managed by ASMLib using the device major and minor  number.

Table of Contents:

–          Physical disks Major and Minor number?

–          Overview of Oracle Automatic Storage Management (ASM)

–          Dealing with ASM disks, Major and Minor number.

–          Creation of a script.

 

1. Physical disks Major and Minor number:

The Linux kernel represents character and block devices as pairs of numbers <major>:<minor>.

Some major numbers are reserved for particular device drivers. Other major numbers are dynamically assigned to a device driver when Linux boots. for more info.

2. Overview of Oracle Automatic Storage Management (ASM):

ASM is a volume manager and a file system for Oracle database files that supports single-instance Oracle Database and Oracle Real Application Clusters (Oracle RAC) configurations. ASM is Oracle’s recommended storage management solution that provides an alternative to conventional volume managers, file systems, and raw devices. for more info.

3. Dealing with ASM disks, Major and Minor number:

Creation of ASM disks on Oracle Linux using ASMLib.

Step 1: To list ASM disks:

$ /etc/init.d/oracleasm listdisks
ASM1
ASM2
ASM3

Step 2:To check  the major and minor value of a given ASM disk:

$ oracleasm querydisk -d ASM1
Disk "ASM1" is a valid ASM disk on device [252, 2]
$ oracleasm querydisk -d ASM2
Disk "ASM2" is a valid ASM disk on device [252, 3]
$ oracleasm querydisk -d ASM3
Disk "ASM3" is a valid ASM disk on device [252, 4]

Step 3: ASM disk mapped to physical disk:

$ ls -l /dev/* | grep "252, *2" | awk '{ print $10 }'
/dev/dm-2
$ ls -l /dev/* | grep "252, *3" | awk '{ print $10 }'
/dev/dm-3
$ ls -l /dev/* | grep "252, *4" | awk '{ print $10 }'
/dev/dm-4

4. Creation of a script:

This script can list all physical disks which they used by ASMLib.

$ cat asm_mapped_ph_disks.sh
/etc/init.d/oracleasm listdisks > /tmp/listdisks.txt
while read -r ASM_disk ; do
major="$(/etc/init.d/oracleasm querydisk -d $ASM_disk | awk -F[ '{ print $2 }'| awk -F] '{ print $1 }' | awk -F, '{ print $1 }')"
minor="$(/etc/init.d/oracleasm querydisk -d $ASM_disk | awk -F[ '{ print $2 }'| awk -F] '{ print $1 }' | awk -F, '{ print $2 }')"
disk_name=$(ls -l /dev/* | grep ^b | grep "$major, *$minor" | awk '{ print $10 }')
echo "The ASM disk: '$ASM_disk' mapped to '$disk_name' "
done < /tmp/listdisks.txt

$ . oraenv
ORACLE_SID = [+ASM] ? +ASM
$ bash asm_mapped_ph_disks.sh
The ASM disk: 'ASM1' mapped to '/dev/dm-2'
The ASM disk: 'ASM2' mapped to '/dev/dm-3'
The ASM disk: 'ASM3' mapped to '/dev/dm-4'

Conclusion:

This article describes how to find the physical Linux disk which mapped to ASM disk.

Bookmark the permalink.
Loading Facebook Comments ...

Leave a Reply