How to use udev rules instead of ASMLIB to configure LUNs for Oracle 11g ASM on Red Hat Enterprise Linux 6.4

Oracle ASM depends upon the names of each LUN device to determine which LUN belongs in a disk group. The problem with Linux is that these LUN device names may change upon reboot. In the past I have used ASMLIB from Oracle to help with this but I found that udev rules are actually easier to use and do not rely on third-party software to get the job done.

I will use the following LUNs for this example:

PurposeSizeDevice Name
DATA50 GB/dev/sddlmab
FRA30 GB/dev/sddlmac
TEMP20 GB/dev/sddlmad
REDO10 GB/dev/sddlmae

Udev rules can be used to give consistent names to devices when the server boots. In order to do this you need a unique identifier for each LUN that does not change on boot. This identifier is the SCSI ID. You can get this using the scsi_id command against each LUN device name:



# scsi_id --page=0x83 --whitelisted --device=/dev/sddlmab
360060e80132756005020275600000061
# scsi_id --page=0x83 --whitelisted --device=/dev/sddlmac
360060e80132756005020275600000062
# scsi_id --page=0x83 --whitelisted --device=/dev/sddlmad
360060e80132756005020275600000063
# scsi_id --page=0x83 --whitelisted --device=/dev/sddlmae
360060e80132756005020275600000064
Now you can create a udev rules script under /etc/udev/rules.d. You want this script to execute after all the other udev scripts so give it a name starting with 99-. For example: 99-asm.rules (udev rules scripts must end with the .rules extension.) In this script you can give persistent names to each LUN using symbolic links. It will also set the ownership and permissions for the device files pointed to by the symbolic links. In this case I am giving meaningful names that correspond to the diskgroup each LUN will join.

KERNEL=="sd*", PROGRAM=="scsi_id --page=0x83 --whitelisted --device=/dev/%k", \
RESULT=="360060e80132756005020275600000061", \
SYMLINK+="oracleasm/disks/DATA01", OWNER="grid", GROUP="oinstall", MODE="0660"

KERNEL=="sd*", PROGRAM=="scsi_id --page=0x83 --whitelisted --device=/dev/%k", \
RESULT=="360060e80132756005020275600000062", \
SYMLINK+="oracleasm/disks/FRA01", OWNER="grid", GROUP="oinstall", MODE="0660"

KERNEL=="sd*", PROGRAM=="scsi_id --page=0x83 --whitelisted --device=/dev/%k", \
RESULT=="360060e80132756005020275600000063", \
SYMLINK+="oracleasm/disks/TEMP01", OWNER="grid", GROUP="oinstall", MODE="0660"

KERNEL=="sd*", PROGRAM=="scsi_id --page=0x83 --whitelisted --device=/dev/%k", \
RESULT=="360060e80132756005020275600000064", \
SYMLINK+="oracleasm/disks/REDO01", OWNER="grid", GROUP="oinstall", MODE="0660"

After a reboot, the symbolic links look like this:

# ls -lt /dev/oracleasm/disks/
total 0
lrwxrwxrwx 1 root root 13 Nov 21 14:54 FRA01 -> ../../sddlmac
lrwxrwxrwx 1 root root 13 Nov 21 14:54 DATA01 -> ../../sddlmab
lrwxrwxrwx 1 root root 13 Nov 21 14:54 REDO01 -> ../../sddlmae
lrwxrwxrwx 1 root root 13 Nov 21 14:54 TEMP01 -> ../../sddlmad
Now you can create the diskgroups using ASM. In this example I use asmca and you can see that it is easy to identify which LUNs belong to which diskgroup: