First time using serverfault, please excuse any breaches of etiquette.
I've created several LVM2 logical volumes in local storage on a server, and would like one of the device nodes - not the filesystem or mount point - to be owned by a user/group other than root:root.
This is pretty much a default RHEL5 server. I understand that the device node is created dynamically at boot time after LVM scans the disks for pv/vg/lvs. I'm not really sure how udev, mapper, and lvm interact to create these nodes, and the configuration file specs are a little cryptic for someone without much experience.
There will be more lvs to follow that also need alternate permissions, but I'd ideally like to keep the other lvs in the volume group at root:root, and only change specific ones.
Can anyone help me figure this one out? I've been googling for hours.
Thanks in advance, Tony
Update:
I accomplished this through the following. It may be a roundabout way of doing things, but this is only a temporary environment (famous last words!). Oh, I may also want to remove the lines that print to /tmp/foo.
[root@xxxxxxx rules.d]# **cat /etc/udev/rules.d/11-lvm.rules**
ACTION=="add|change", KERNEL=="dm-*", PROGRAM="/bin/sh -c /etc/udev/scripts/oracle_perms.sh"
[root@xxxxxxx rules.d]# **cat /etc/udev/scripts/oracle_perms.sh**
#!/bin/bash
echo "DEVPATH=$DEVPATH" >> /tmp/foo
MAJMIN=`cat /sys${DEVPATH}/dev`
echo "MAJMIN=$MAJMIN" >> /tmp/foo
MAJ=`echo ${MAJMIN} | awk -F: '{ print $1 }'`
MIN=`echo ${MAJMIN} | awk -F: '{ print $2 }'`
DEVNODE=`/sbin/dmsetup info -j ${MAJ} -m ${MIN} | grep Name | awk '{ print $2 }'`
echo "DEVNODE=${DEVNODE}" >> /tmp/foo
echo "${DEVNODE}" | grep ora >/dev/null 2>&1
if [ "$?" == "0" ]; then
echo "Making change...." >> /tmp/foo
chown oracle:dba /dev/mapper/${DEVNODE}
chmod 660 /dev/mapper/${DEVNODE}
ls -l /dev/mapper/${DEVNODE} >> /tmp/foo
else
echo "No 'ora' name detected. No change necessary." >> /tmp/foo
fi
Note that the solution above automagically changes ANY LV that's created with "ora" in the name. Hey, it works for now.