mdev – mini udev in busybox
发布日期:2025-04-13 12:29:16 浏览次数:13 分类:精选文章

本文共 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:

  • Mount sysfs at /sys.
  • Echo the mdev binary path to /proc/sys/kernel/hotplug.
  • Execute mdev -s to create device nodes.
  • A more comprehensive setup involves:

  • Mounting tmpfs at /dev for mdev functionality.
  • Creating the /dev/pts directory.
  • Mounting devpts on /dev/pts.
  • 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.

    上一篇:Windows server 2003到Windows server 2008 R2的迁移本地升级
    下一篇:MD5的算法(C)

    发表评论

    最新留言

    初次前来,多多关照!
    [***.217.46.12]2025年05月25日 17时39分25秒

    关于作者

        喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
    -- 愿君每日到此一游!

    推荐文章