Using udev on RHEL 6 / OL 6 to change disk permissions for ASM

fritshoogland's picture

When you use Oracle ASM (Automatic Storage Management) for your database, the permissions on the block devices on the operating system layer which are used by ASM need to be changed. To be more precise, the owner and group need to be set to ‘oracle’ and ‘dba’ (Oracle documentation) in my case.

I used to do this in a very lazy way, using a simple ‘/bin/chown oracle.dba /dev/sdb’ in /etc/rc.local. This worked for me with RHEL/OL version 5. This has changed with RHEL/OL 6, because the system V startup system has changed to ‘upstart’. Also, the disk devices change ownership back in OL6 if you set it by hand to oracle.dba.

Oracle has its own resolution for generating block device files especially for ASM, called ASMLib. This generally works well, but what is exactly happening to generate the devices, and how to troubleshoot the generation of the devices is (as far as I know) not documented nor generally known. I’ve been bitten a few times on my test systems, which is the reason I don’t like ASMLib, and do not feel comfortable with ASMLib.

The linux system has functionality which equals the block device generation of ASMLib, which is called udev. Udev isn’t exactly over-documented. Also, there seems to be a difference between the tools (scsi_id and rule file syntax) in RHEL/OL 5 and RHEL/OL 6. But there is much written about it. And it’s very simple, once you know what to do.

I have a separate (virtual) disk which I want to use with ASM. After startup, the block device of this disk is called /dev/sdb. In order to let udev identify this disk, the linux utility ‘scsi_id’ can be used to fetch the unique SCSI identifier of the disk. This is of importance, because the correct disk must be specified to be used with ASM. This sounds a bit dumb (of course we need the correct disk), but Linux names the devices in the order at which they are seen by the kernel. This means it’s possible that /dev/sdb is another disk if someone decides to add a disk to the system, and reboots the server. (please mind most servers do not change very much, nor I have seen this happening)

And there’s another complication: VMWare doesn’t provide a unique device number by default. In order to let VMWare provide Linux a unique number, ‘disk.EnableUUID = “TRUE”‘ must be added to the virtual machine configuration file (“vmx file”). After a reboot, ‘scsi_id’ is able to provide a serial!

So at this point, you should have a disk or disks to be used with ASM. First grab the unique serial of the disk (this is the RHEL6/OL6 syntax of the scsi_id command!):

# scsi_id -g -u -d /dev/sdb

Next, we need to make a udev rule file. In this file, we specify this SCSI id (which we fetched with scsi_id), and specify how we want that device created:

# cd /etc/udev/rules.d/
# cat 99-oracle-asmdevices.rules

KERNEL=="sd*", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="36000c29127c3ae0670242b058e863393", NAME+="oracleasm/disk1", OWNER="oracle", GROUP="dba", MODE="0660"

(There is no ’99-oracle-asmdevices.rules’ file by default, you need to create it yourself)

That’s all. When the kernel finds a “sd*” device, subsystem “block”, with the serial “36000c29127c3ae0670242b058e863393″, it creates a device file ‘/dev/oracleasm/disk1′, owner oracle, etc.

This is also convenient because the disk string of ASM is very easy to set now: ‘/dev/oracleasm/*’.

Please mind if the block devices have the correct permissions, it doesn’t matter to ASM if the device file names have swapped. The ASM instance scans the device headers for it’s contents.

Tagged: oracle linux udev ASM device blockdevice

To prevent automated spam submissions leave this field empty.