When a logical volume is used for ASM
disk, the logical volume should be given ownership grid infrastructure user and
group. This can be set simply by adding chown commands /etc/rc.local file (a
dirty work around). The same thing can be accomplished even by using udev rules
like below.
In this example, we are trying to use logical volume vol05 in volume group vg1 for grid infrastructure.
Add below line to /etc/udev/rules.d/91-lvm- asmdisk.rules (entire content in single line)
In this example, we are trying to use logical volume vol05 in volume group vg1 for grid infrastructure.
Add below line to /etc/udev/rules.d/91-lvm-
SUBSYSTEM=="block",
KERNEL=="dm-*", ACTION=="add|change", PROGRAM="/sbin/dmsetup
info -c --noheadings -o name -j %M -m %m", RESULT=="vg1-vol05",
RUN+="/bin/chown grid:asmadmin /dev/mapper/vg1-vol05"
Deactivate and activate logical volume to verify if udev rule is working fine.
# lvchange -an
vg1/vol05
# lvchange -ay vg1/vol05
# lvchange -ay vg1/vol05
Now ownership is
changed for logical volume.
# ls -l
/dev/mapper/vg1-vol05
brw-rw---- 1 grid asmadmin 253, 4 Dec 14 22:33 /dev/mapper/vg1-vol05
brw-rw---- 1 grid asmadmin 253, 4 Dec 14 22:33 /dev/mapper/vg1-vol05
Excellent job, thanks!!
ReplyDeleteThank you :-)
DeleteCan this be completed with using a wildcard for multiple volumes.
DeleteRUN+="/bin/chown grid:asmadmin /dev/mapper/vg1-vol*"
I think wild cards will not work here, as the udev rule mentioned checks for name of volume explicitly, you can see RESULT=="vg1-vol05" in the rule.
ReplyDeleteFor multiple volumes, the PROGRAM should be a script that verifies the logical volumes that needed to changed ownership instead of dmsetup command. And based on RESULT of the script RUN command should be "/bin/chown grid:asmadmin %p"
So, roughly the udev rule will like this (I have not tested this, just giving like a hint)
SUBSYSTEM=="block", KERNEL=="dm-*", ACTION=="add|change", PROGRAM="/usr/bin/check_vol.sh %M %m", RESULT=="YES", RUN+="/bin/chown grid:asmadmin %p"
And create script /usr/bin/check_vol.sh like this
#!/bin/bash
volname=`/sbin/dmsetup info -c --noheadings -o name -j $1 -m $2`
if [ *** write your logic to check if $volname should be changed ownership *** ]
then
echo YES
else
echo NO
fi
Please let me know if this works. I do not have this setup of LVM for ASM anymore. So, I can guess and give answers, but I could not test right now.
Hi Murty
ReplyDeleteOne question about this
Are you saying that the following wont work?
/etc/udev/rules.d/90-lvm.rules
SUBSYSTEM=="block", KERNEL=="dm-*", ACTION=="add|change", PROGRAM="/sbin/dmsetup info -c --noheadings -o name -j %M -m %m", RESULT=="vg1-vol05", RUN+="/bin/chown grid:asmadmin /dev/mapper/vg1-vol05"
SUBSYSTEM=="block", KERNEL=="dm-*", ACTION=="add|change", PROGRAM="/sbin/dmsetup info -c --noheadings -o name -j %M -m %m", RESULT=="vg1-vol04", RUN+="/bin/chown grid:asmadmin /dev/mapper/vg1-vol04"
Thanks in advance
Nacho
Hey, it's not work for me !
DeleteEvery reboot I need to run lvchange -an /dev/mapper/vg1 ; lvchange -ay /dev/mapper/vg1 then it's work.
someone ?
Hi Nacho,
ReplyDeleteIt works, but, if we have many volume groups, we need to add a line for each of them. What I was giving in my last reply, a way to write single rule that can be used for multiple logical volumes.
Murty