bind raw devices using UDEV

1) bind the local disks to raw devices using UDEV RULES
1@@@@ make sure you have the disk
[root@station123 ~]# fdisk -l /dev/sda

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe70af055

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        1044     8385898+   5  Extended
/dev/sda5               1         132     1060227   83  Linux
/dev/sda6             133         264     1060258+  83  Linux
/dev/sda7             265         396     1060258+  83  Linux
/dev/sda8             397         528     1060258+  83  Linux

Note:
  here, I use /dev/sda5 6 7 8 as the raw devices



2@@@@ create the udev rules
[root@station123 ~]# cat /etc/udev/rules.d/60-raw.rules
# Enter raw device bindings here.
#
# An example would be:
#   ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"
# to bind /dev/raw/raw1 to /dev/sda, or
#   ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m"
# to bind /dev/raw/raw2 to the device with major 8, minor 1.

ACTION=="add", KERNEL=="sda5", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sda6", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sda7", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="sda8", RUN+="/bin/raw /dev/raw/raw4 %N"



3@@@@ create the udev rules privileges of raw devices
[root@station123 ~]# cat /etc/udev/rules.d/50-udev.rules
KERNEL=="raw1", OWNER="oracle" GROUP="oinstall", MODE="0660"
KERNEL=="raw2", OWNER="oracle" GROUP="oinstall", MODE="0660"
KERNEL=="raw3", OWNER="oracle" GROUP="oinstall", MODE="0660"
KERNEL=="raw4", OWNER="oracle" GROUP="oinstall", MODE="0660"



4@@@@ after reboot
[root@station123 ~]# reboot

[root@station123 ~]# ll /dev/raw/raw*
crw-rw----. 1 oracle oinstall 162, 1 May  4 12:34 /dev/raw/raw1
crw-rw----. 1 oracle oinstall 162, 2 May  4 12:34 /dev/raw/raw2
crw-rw----. 1 oracle oinstall 162, 3 May  4 12:34 /dev/raw/raw3
crw-rw----. 1 oracle oinstall 162, 4 May  4 12:34 /dev/raw/raw4
crw-rw----. 1 root   disk     162, 0 May  4 12:34 /dev/raw/rawctl

[root@station123 ~]# raw -qa
/dev/raw/raw1:    bound to major 8, minor 5
/dev/raw/raw2:    bound to major 8, minor 6
/dev/raw/raw3:    bound to major 8, minor 7
/dev/raw/raw4:    bound to major 8, minor 8


5@@@@ complement
we can use command like below, you would create raw device temporily.
[root@station123 ~]# raw /dev/raw/raw1 /dev/sda5

 

你可能感兴趣的:(udev)