linux 配置udev修改权限

网友投稿 1039 2022-05-29

本次介绍使用udev修改磁盘权限。

linux 配置udev修改权限

参考模板位置:/usr/share/doc/device-mapper-1.02.170/12-dm-permissions.rules

#编写规则:(任选一条即可)

/etc/udev/rules.d/99-oracle-asm.rules ENV{DM_UUID}=="mpath-?*", OWNER:="grid", GROUP:="asmadmin", MODE:="660"* ENV{DM_UUID}=="mpath-?*", OWNER:="grid", GROUP:="asmadmin", MODE:="660",SYMLINK+="asmdisk_%k"* *ENV{DM_UUID}=="mpath-?*", OWNER:="grid", GROUP:="asmadmin", MODE:="660",SYMLINK="asmdisk_%k"

#重新加载规则

udevadm control -R udevadm trigger

测试步骤和结果:

[root@hecs-66a2 ~]# ll /usr/share/doc/device-mapper-1.02.170/12-dm-permissions.rules -rw-r--r-- 1 root root 3186 Mar 25 2020 /usr/share/doc/device-mapper-1.02.170/12-dm-permissions.rules [root@hecs-66a2 ~]# multipath -l mpathb (36001405a8111ea8e7e54c8fb25613092) dm-1 LIO-ORG ,disk02 size=20G features='0' hwhandler='0' wp=rw `-+- policy='service-time 0' prio=0 status=active `- 2:0:0:1 sdb 8:16 active undef running mpatha (360014054170ebd76f8b4cd69600e1ba9) dm-0 LIO-ORG ,disk01 size=10G features='0' hwhandler='0' wp=rw `-+- policy='service-time 0' prio=0 status=active `- 2:0:0:0 sda 8:0 active undef running [root@hecs-66a2 ~]# cat /etc/udev/rules.d/99-oracle-asm.rules ENV{DM_UUID}=="mpath-?*", OWNER:="grid", GROUP:="asmadmin", MODE:="660",SYMLINK+="asmdisk_%k" [root@hecs-66a2 ~]# udevadm admin -R udevadm: missing or unknown command [root@hecs-66a2 ~]# udevadm control -R [root@hecs-66a2 ~]# udevadm trigger [root@hecs-66a2 ~]# ll /dev/asmdisk_dm-* lrwxrwxrwx 1 root root 4 Oct 30 09:32 /dev/asmdisk_dm-0 -> dm-0 lrwxrwxrwx 1 root root 4 Oct 30 09:32 /dev/asmdisk_dm-1 -> dm-1 [root@hecs-66a2 ~]# ll /dev/dm-* brw-rw---- 1 grid asmadmin 252, 0 Oct 30 09:32 /dev/dm-0 brw-rw---- 1 grid asmadmin 252, 1 Oct 30 09:32 /dev/dm-1

# SYMLINK+与 SYMLINK区别?

SYMLINK+ create a symbolic link 。 SYMLINK: instead of calling it 。 * SYMLINK - a list of symbolic links which act as alternative names for the device node As hinted above, udev only creates one true device node for one device. If you wish to provide alternate names for this device node, you use the symbolic link functionality. With the SYMLINK assignment, you are actually maintaining a list of symbolic links, all of which will be pointed at the real device node. To manipulate these links, we introduce a new operator for appending to lists: +=. You can append multiple symlinks to the list from any one rule by separating each one with a space. KERNEL=="hdb", NAME="my_spare_disk" The above rule says: match a device which was named by the kernel as hdb, and instead of calling it hdb, name the device node as my_spare_disk. The device node appears at /dev/my_spare_disk. KERNEL=="hdb", DRIVER=="ide-disk", SYMLINK+="sparedisk" The above rule says: match a device which was named by the kernel as hdb AND where the driver is ide-disk. Name the device node with the default name and create a symbolic link to it named sparedisk. Note that we did not specify a device node name, so udev uses the default. In order to preserve the standard /dev layout, your own rules will typically leave the NAME alone but create some SYMLINKs and/or perform other assignments. KERNEL=="hdc", SYMLINK+="cdrom cdrom0" The above rule is probably more typical of the types of rules you might be writing. It creates two symbolic links at /dev/cdrom and /dev/cdrom0, both of which point at /dev/hdc. Again, no NAME assignment was specified, so the default kernel name (hdc) is used.

Linux

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:MySQL索引下推,原来这么简单!
下一篇:电脑硬件知识入门之CPU篇
相关文章