linux 配置udev修改權(quán)限
本次介紹使用udev修改磁盤權(quán)限。
參考模板位置:/usr/share/doc/device-mapper-1.02.170/12-dm-permissions.rules
#編寫規(guī)則:(任選一條即可)
/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"
#重新加載規(guī)則
udevadm control -R udevadm trigger
測試步驟和結(jié)果:
[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區(qū)別?
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
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實后本網(wǎng)站將在24小時內(nèi)刪除侵權(quán)內(nèi)容。