In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
What is the match key and RAW of UDEV rules? for this question, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
The udevadm command can see the specific information udevadm info-- attribute-walk-- name=/dev/sda
Some common directory information involved in UDEV
Ll / sys/class/block/
Ll / dev/raw
Ll / dev/mapper
Ll / dev/block
Ll / dev/disk/by-path
Ll / dev/disk/by-id
Ll / dev/disk/by-uuid
Match field properties of UDEV rules
ACTION matches the action name of the event, for example: add (add device), remove (remove device).
The DEVPATH matches the device-relative path of the event. For example, the devpath for sda is / dev/sda,sda2 and the devpath is / dev/sda2.
KERNEL matches the name of the device for the event, such as sdb, such as sd* for any SCSI disk device
The NAME matches the name of the network interface or device node. NAME can only be used after the previous rule has been assigned.
The SYMLINK matches the name of the symbol chain of the device node. SYMLINK can only be used after the previous rule has been assigned. There can be multiple symlinks, and only one needs to be matched.
SUBSYSTEM matching equipment subsystem
DRIVER matches the device driver name of the device in devpath, for example: ide-cdrom.
The bus name of the BUS device in devpath, for example: usb.
Identification number of ID device in devpath
ENV {key} environment variable. ENV {MAJOR} = = "8" and ENV {MINOR} = = "1" for sda1
PROGRAM executes a program. If the program returns successfully, key is true. The properties of the device are placed in the environment variable of the executing process, and the output of the program is stdout, which can be read from the key of RESULT.
RESULT matches the return string from the most recent PROGRAM call. It should be used after PROGRAM.
OWNER matches the subordinate group of the device file
GROUP matches the group in which the device file is located.
MODE matches the permissions of the device file, using octal
MAJOR represents the disk number
MINOR represents the partition number under the disk
UDEV rules match field properties and callable replacement operators
$kernel,% k: the kernel device name of the device, for example: sda, cdrom.
$number,% n: the kernel number of the device, for example: the kernel number of sda3 is 3.
$devpath,% p: the devpath path of the device.
$id,% b: the ID number of the device in devpath.
$sysfs {file},% s {file}: the contents of the file in the sysfs of the device. It is actually the property value of the device.
$env {key},% E {key}: the value of an environment variable.
$major,% M: major number of the device.
$minor% m: minor number of the device.
$result, the result returned by% c:PROGRAM.
$parent,% P: the device file name of the parent device.
$root, the value of% r:udev_root, defaults to / dev/.
$tempnode,% N: temporary device name.
%%: symbol% itself.
$: symbol $itself.
Special description of ENV {key}
The different devices indicated in the linux kernel are implemented through major and minor number, and the corresponding drivers are loaded through major and minor Number.
The major number of both sda and sdb is 8. SDA's minor number starts with 0 and sdb's minor number starts with 16.
ENV {major} major indicates different device types
ENV {minor} minor represents different partitions of the same device
ACTION== "add", KERNEL== "sda", RUN+= "/ bin/raw / dev/raw/raw1 N"
ACTION== "add", ENV {MAJOR} = = "8", ENV {MINOR} = = "1", RUN+= "/ bin/raw / dev/raw/raw2% M% m"
Raw command (in the past, the RHEL4 version used more, now RHEL6 uses less, but RHEL6 can also use this way)
You can bind a bare device directly through the raw command, but it will be lost after reboot. It needs to be written in / etc/sysconfig/rawdevices file, such as / dev/raw/raw1 / dev/sdb1.
[root@localhost ~] # ll / dev/raw
Total dosage 0
Crw-rw----. 1 root disk 162,06 June 23 16:58 rawctl
[root@localhost ~] # raw
Usage:
Raw/ dev/raw/rawN
Raw/ dev/raw/rawN / dev/
Raw-Q / dev/raw/rawN
Raw-qa
[root@localhost ~] # raw/ dev/raw/raw1 / dev/sdb1
/ dev/raw/raw1: bound to major 8, minor 17
[root@localhost ~] # ll / dev/ | grep sdb
Brw-rw----. 1 root disk 8, 16 June 23 16:59 sdb
Brw-rw----. 1 root disk 8, 17 June 23 16:59 sdb1
[root@localhost ~] # raw-qa
/ dev/raw/raw1: bound to major 8, minor 17
[root@localhost] # raw-Q / dev/raw/raw1
/ dev/raw/raw1: bound to major 8, minor 17
[root@localhost ~] # ll / dev/raw
Total dosage 0
Crw-rw----. 1 root disk 162,16 June 23 17:25 raw1
Crw-rw----. 1 root disk 162,06 June 23 16:58 rawctl
[root@localhost ~] # cat / etc/issue
CentOS release 6.5 (Final)
Kernel\ r on an\ m
This is the answer to the match key of UDEV rules and what is RAW. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.