Linux udev: Difference between revisions
From Lolly's Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
==udev | ==udev for MySQL on LVM with InnoDB on raw devices== | ||
===Make your rule=== | ===Make your rule=== | ||
Line 51: | Line 46: | ||
root@mysql:~# ls -alL /dev/vg-data/lv-rawdisk-innodb01 | root@mysql:~# ls -alL /dev/vg-data/lv-rawdisk-innodb01 | ||
brw-rw---- 1 mysql mysql 252, 0 Aug 12 15:07 /dev/vg-data/lv-rawdisk-innodb01 | brw-rw---- 1 mysql mysql 252, 0 Aug 12 15:07 /dev/vg-data/lv-rawdisk-innodb01 | ||
</source> | |||
==VirtualBox on ZVols== | |||
This owns all ZVols under rpool/VM to the user <i>lollypop</i>: | |||
* /etc/udev/rules.d/99-local-zvol.rules | |||
<source lang=bash> | |||
KERNEL=="zd*" SUBSYSTEM=="block" ACTION=="add|change" PROGRAM="/lib/udev/zvol_id /dev/%k" RESULT=="rpool/VM/*" OWNER="lollypop" | |||
</source> | </source> |
Revision as of 14:23, 22 January 2016
udev for MySQL on LVM with InnoDB on raw devices
Make your rule
root@mysql:~# cat /etc/udev/rules.d/99-lvm-mysql-permissions.rules
# udevadm info --query=all --name /dev/vg-data/lv-rawdisk-innodb01
# DM_VG_NAME=vg-data
# DM_LV_NAME=lv-rawdisk-innodb01
ENV{DM_VG_NAME}=="vg-data" ENV{DM_LV_NAME}=="lv-rawdisk-innodb*" OWNER="mysql" GROUP="mysql"
Test your rule
root@mysql:~# ls -al /dev/vg-data/lv-rawdisk-innodb01
lrwxrwxrwx 1 root root 7 Aug 12 14:45 /dev/vg-data/lv-rawdisk-innodb01 -> ../dm-0
root@mysql:~# udevadm test /class/block/dm-0
...
read rules file: /etc/udev/rules.d/99-lvm-mysql-permissions.rules
specified user 'mysql' unknown
...
OK user mysql unknown... maybe I should install MySQL ;-).
After that:
root@mysql:~# id -a mysql
uid=108(mysql) gid=114(mysql) groups=114(mysql)
root@mysql:~# udevadm test /class/block/dm-0
...
OWNER 108 /etc/udev/rules.d/99-lvm-mysql-permissions.rules:4
GROUP 114 /etc/udev/rules.d/99-lvm-mysql-permissions.rules:4
handling device node '/dev/dm-0', devnum=b252:0, mode=0660, uid=108, gid=114
set permissions /dev/dm-0, 060660, uid=108, gid=114
...
Trigger your rule
root@mysql:~# udevadm trigger
root@mysql:~# ls -alL /dev/vg-data/lv-rawdisk-innodb01
brw-rw---- 1 mysql mysql 252, 0 Aug 12 15:07 /dev/vg-data/lv-rawdisk-innodb01
VirtualBox on ZVols
This owns all ZVols under rpool/VM to the user lollypop:
- /etc/udev/rules.d/99-local-zvol.rules
KERNEL=="zd*" SUBSYSTEM=="block" ACTION=="add|change" PROGRAM="/lib/udev/zvol_id /dev/%k" RESULT=="rpool/VM/*" OWNER="lollypop"