
本文共 1634 字,大约阅读时间需要 5 分钟。
MDEV Primer: Understanding and Usage Guide
For those familiar with mdev, this primer may seem redundant. For others, mdev is a mysterious black box that is touted as powerful but not easily understood. Thus, this primer.
Basic Use of Mdev
Mdev serves two primary purposes: initial device population and dynamic updates. Both require sysfs kernel support, mounted at /sys. For dynamic updates, kernel hotplugging must be enabled.
A typical initialization script might include the following steps:
A more comprehensive setup involves:
These steps ensure /sys is mounted before mdev execution, enabling device node creation upon device addition or removal.
MDEV Configuration (/etc/mdev.conf)
Mdev offers optional configuration for device node ownership and permissions, deviating from the default root/root 660 settings. The configuration file format is:
For example:
hd[a-z][0-9]* 0:3 660
Parsing stops at the first match. If none match, defaults (0:0 660) apply. To set a default, use a regex like .* 1:1 777.
For advanced use, the format includes command execution:
Special characters trigger commands at specific lifecycle stages. Commands are executed via /bin/sh, so ensure sh is installed at /bin/sh. The $MDEV variable provides the device name for convenience.
This guide provides a clear understanding of mdev configuration and usage, ensuring effective device management on your system.
发表评论
最新留言
关于作者
