11

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.

Benoit Duffez
  • 143
  • 2
  • 11
user626201
  • 231
  • 1
  • 2
  • 7

3 Answers3

6

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.

Daniel Böhmer
  • 259
  • 1
  • 11
  • So if `/dev` devices are not being created, could be a problem with `mdev` or a timing issue? –  May 03 '11 at 12:49
  • Yes, as far as I understand both could be true. But I only wrote the answer because I had just read about mdev in a news article yesterday. Generally I have no experience with it and cannot give any further assistance. That's why I posted my answer as a kick-start for a community wiki answer. –  May 03 '11 at 14:07
4

Here is a link to the mdev primer.

1

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.