public:it:linux:udev

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版
前一修订版
public:it:linux:udev [2023/11/30 13:12] oakfirepublic:it:linux:udev [2023/12/25 15:38] (当前版本) oakfire
行 4: 行 4:
 - `KERNEL / SUBSYSTEM / DRIVER / ATTR` 只匹配本设备不匹配父设备.  加个`S`, 就可以在本设备以及父设备整条链上搜索匹配。 `KERNELS / SUBSYSTEMS / DRIVERS / ATTRS` - `KERNEL / SUBSYSTEM / DRIVER / ATTR` 只匹配本设备不匹配父设备.  加个`S`, 就可以在本设备以及父设备整条链上搜索匹配。 `KERNELS / SUBSYSTEMS / DRIVERS / ATTRS`
 - 字符匹配: - 字符匹配:
- ```+ ```bash
  * - match any character, zero or more times  * - match any character, zero or more times
  ? - match any character exactly once  ? - match any character exactly once
行 10: 行 10:
  ```  ```
 - 替换符 - 替换符
- ``` + 
- $kernel, %k:        设备的内核设备名称,例如:sda、cdrom。 + ```bash 
- $number, %n:        设备的内核号码,例如:sda3 的内核号码是 3 + $kernel, %k   The kernel name for this device. 
- $devpath, %p:       设备的 devpath路径。 + $number, %n   The kernel number for this device. For example, "sda3" has kernel number 3. 
- $id, %b:          设备在 devpath里的 ID 号。 + $devpath, %p The devpath of the device. 
- $sysfs{file}, %s{file}:     设备的 sysfs里 file 的内容。其实就是设备的属性值。 + $id, %b The name of the device matched while searching the devpath upwards for SUBSYSTEMS, KERNELS, DRIVERS, and ATTRS. 
- $env{key}%E{key}:   一个环境变量的值。 + $driver The driver name of the device matched while searching the devpath upwards for SUBSYSTEMS, KERNELS, DRIVERS, and ATTRS. 
- $major%M:        设备的 major 号。 + $attr{file}, %s{file} The value of a sysfs attribute found at the device where all keys of the rule have matched. If the matching 
- $minor %m:        设备的 minor 号。 + device does not have such an attributeand a previous KERNELSSUBSYSTEMSDRIVERS, or ATTRS test selected a 
- $result%c:        PROGRAM 返回的结果。 + parent devicethen the attribute from that parent device is used. 
- $parent, %P:          父设备的设备文件名。 + If the attribute is a symlinkthe last element of the symlink target is returned as the value. 
- $root%r:          udev_root的值,默认是 /dev/。 + %%: 符号 % 本身。 
- $tempnode, %N:      临时设备名。 + $$: 符号 $ 本身。
- %%:            符号 % 本身。 +
- $$:             符号 $ 本身。+
  ```  ```
 - 获取设备信息: - 获取设备信息:
行 35: 行 33:
   - 或者 `udevadm control -R`   - 或者 `udevadm control -R`
 -  `NAME=` 只对网路设备起作用 -  `NAME=` 只对网路设备起作用
-```+```bash
 NAME NAME
        The name to use for a network interface. See        The name to use for a network interface. See
行 46: 行 44:
 ## 示例 ## 示例
 - ubuntu默认的usb storage mount 规则 `/etc/udev/rules.d/10-usb-storage.rules` : - ubuntu默认的usb storage mount 规则 `/etc/udev/rules.d/10-usb-storage.rules` :
-```+```bash
 KERNEL!="sd[a-z][0-9]",GOTO="automount_exit" KERNEL!="sd[a-z][0-9]",GOTO="automount_exit"
 ACTION=="add", SUBSYSTEM=="block", RUN+="/bin/mkdir -p /media/%k", RUN+="/usr/bin/mount $devnode /media/%k" ACTION=="add", SUBSYSTEM=="block", RUN+="/bin/mkdir -p /media/%k", RUN+="/usr/bin/mount $devnode /media/%k"
行 56: 行 54:
  
 - 指定类型 - 指定类型
-```+```bash
 ACTION=="add", KERNEL=="sd*[0-9]", SUBSYSTEMS=="block", SYMLINK+="sd-myself", ATTRS{model}=="Your_Harddisk_Model"` ACTION=="add", KERNEL=="sd*[0-9]", SUBSYSTEMS=="block", SYMLINK+="sd-myself", ATTRS{model}=="Your_Harddisk_Model"`
 ``` ```
 </markdown> </markdown>
  • public/it/linux/udev.1701321144.txt.gz
  • 最后更改: 2023/11/30 13:12
  • oakfire