LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to change the LVM logical volume owner in RHEL 5.3 (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-change-the-lvm-logical-volume-owner-in-rhel-5-3-a-779078/)

srithi 12-31-2009 09:43 AM

How to change the LVM logical volume owner in RHEL 5.3
 
Hello,

We are running Sybase database in RHEL 5.3 and we use LVM block devices within Sybase. Shown below are some sample devices

/dev/mapper/syb_data_01-data01
/dev/mapper/syb_log_01-tlog01

We change the ownership of the above block devices to sybase and after a node reboot the ownership of the devices goes back to root. Are there any options in LVM to permanently change the ownership of the logical volumes?

I was thinking of putting a shell script in rc.local which will change the ownership of the Sybase devices during a node reboot. Is there a better way to achieve this?

Any suggestions would be greatly appreciated.

Thanks

phil.d.g 12-31-2009 11:43 AM

I found this quite tricky, and the solution is a kludge, but works.

Here is a set of udev rules that I came up with to do exactly what you want, but for another reason.

Code:

SUBSYSTEM!="block",            GOTO="kvm_lvm_end"
KERNEL!="dm-*",                GOTO="kvm_lvm_end"
ACTION!="add|change",              GOTO="kvm_lvm_end"

ENV{DM_NAME}=="vg1-kvm_[0-9]*_?*", OWNER:="root", GROUP:="kvm", MODE:="660", \
    RUN+="/bin/chgrp kvm /dev/mapper/$env{DM_NAME}"

LABEL="kvm_lvm_end"

Just edit them to suit your situation, and put them in a file under /etc/udev/rules.d/
then reload and rerun. I can't remember how to do that off the top of my head for RHEL

The kludge is having to execute chgrp, the device at this point will be /dev/dm-X where X is an incrementing number, but we also want the permissions to be correct for the /dev/mapper/vg-lv node

srithi 12-31-2009 12:27 PM

How to change the LVM logical volume owner in RHEL 5.3
 
Thanks Phil. Actually, I don't directly use the dm-* devices, but create the Sybase logical volumes on top of it. So, should I still use KERNEL!="dm-*" OR should I specify a different kernel module name. Please let me know.

Thanks

Quote:

Originally Posted by phil.d.g (Post 3810121)
I found this quite tricky, and the solution is a kludge, but works.

Here is a set of udev rules that I came up with to do exactly what you want, but for another reason.

Code:

SUBSYSTEM!="block",            GOTO="kvm_lvm_end"
KERNEL!="dm-*",                GOTO="kvm_lvm_end"
ACTION!="add|change",              GOTO="kvm_lvm_end"

ENV{DM_NAME}=="vg1-kvm_[0-9]*_?*", OWNER:="root", GROUP:="kvm", MODE:="660", \
    RUN+="/bin/chgrp kvm /dev/mapper/$env{DM_NAME}"

LABEL="kvm_lvm_end"

Just edit them to suit your situation, and put them in a file under /etc/udev/rules.d/
then reload and rerun. I can't remember how to do that off the top of my head for RHEL

The kludge is having to execute chgrp, the device at this point will be /dev/dm-X where X is an incrementing number, but we also want the permissions to be correct for the /dev/mapper/vg-lv node


phil.d.g 12-31-2009 12:34 PM

For every node in /dev/mapper/ there is a corresponding node that takes the form /dev/dm-X, they both point to the same block device.

dm-mod is the kernel module that gives the device mapper functionality so you want to keep the kernel module the same.

When the udev rule is triggered it's due to the creation of /dev/dm-X, at this time the node has already been created in /dev/mapper so aswell as applying the correct ownership and permissions to /dev/dm-X we also need to do it the node in /dev/mapper.

When I have some energy I intend to do look into it more and have a rule triggered on the creation of the /dev/mapper/ node, but one day at a time :)


All times are GMT -5. The time now is 12:45 AM.