What is mdev and how to /dev/* nodes get created in Linux?

30,097

Solution 1

Here is a link to the mdev primer.

Solution 2

mdev is a light-weight alternative to udev for usage in embedded devices. Both handle the creation of device files in /dev and starting of actions when certain events happen.

Solution 3

mdev basically calls mknod for a set of pre-configured device files.

If you have a choice, use instead:

CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y

which automatically mounts the special devtmpfs filesystem under /dev, and allows modules to automatically create their own device files on insmod, as shown at: https://stackoverflow.com/questions/5970595/how-to-create-a-device-node-from-the-init-module-code-of-a-linux-kernel-module/45531867#45531867

This is what Buildroot and most distros currently do by default.

Share:
30,097

Related videos on Youtube

user626201
Author by

user626201

Updated on September 18, 2022

Comments

  • user626201
    user626201 over 1 year

    Our Linux kernel is 2.6.31 running on an embedded MIPS processor with busybox.

    The initialisation script (rcS) starts mdev with:

    echo "/sbin/stbhotplug" > /proc/sys/kernel/hotplug
    mdev -s
    

    Can anyone tell me what the Linux utility mdev does?

    It looks like it does auto hot plugging as the stbhotplug is a script that handle ethernet interfaces.

    Also, the rootfs we have been given only has a console device i.e. /dev/console is the only file in /dev.

    However, when the system is running, the /dev directory is full of device files (e.g. /dev/mtd, etc.).

    The reason I ask is that occasionally we get an error whereby it is reported that /dev/ubi_ctrl is not found or /dev/ubi1 is not found.

    How or when does Linux create these devices?

    Thanks.

  • Admin
    Admin about 13 years
    So if /dev devices are not being created, could be a problem with mdev or a timing issue?
  • Stephan Henningsen
    Stephan Henningsen about 3 years
    Whoa! I had to back step there because I clicked your to-the-point-link so quickly. Here's a well-deserved ^ =)