The mdevd program
mdevd is a uevent manager. It connects to the netlink and reads
a series of uevents; for every uevent it reads, it performs
actions according to its configuration file. Actions can
be inserting a kernel module, creating or modifying device
entries in /dev, etc.
mdevd's configuration file uses the exact same
The differences between mdevd and mdev are:
- mdev needs to be registered as a hotplug manager and the
kernel spawns an instance of mdev per uevent; for every uevent,
mdev has to parse its configuration file. By contrast, mdevd is
a daemon: it's long-lived, and there is only one instance,
reading a series of uevents and
performing actions without forking; the configuration file is
read and parsed only once.
mdevd [ -v verbosity ] [ -D notif ] [ -b kbufsz ] [ -f conffile ] [ -n ] [ -s slashsys ] [ -d slashdev ] [ -F fwbase ]
- mdevd reads and parses its configuration file /etc/mdev.conf.
- It then connects to the netlink and reads from it, waiting for uevents.
- It exits 0 on a SIGTERM.
- 0: SIGTERM received, clean exit
- 1: received an invalid event
- 2: syntax error in the configuration file
- 100: wrong usage
- 111: system call failed
mdevd reacts to the following signals:
- SIGHUP: re-read the configuration file
- SIGTERM: exit as soon as possible
- -v verbosity : be more or less verbose.
Default verbosity is 1. 0 will only print fatal error messages, 3 or more
is seriously verbose debugging.
- -D notif : when ready
(actually listening to the netlink),
write a newline to file descriptor notif then close it.
This allows mdevd to use the
s6 mechanism to notify
readiness. notif cannot be lesser than 3.
If this option is not given, no readiness notification is sent.
- -b kbufsz : try and reserve a kernel buffer of
kbufsz bytes for the netlink queue. Too large a buffer wastes kernel memory;
too small a buffer risks losing events. The default is 500 kB, which should be
enough for most systems; if you're getting "No buffer space available" errors
from mdevd at coldplug time, try increasing this number.
- -n : dry run. mdevd will not create or delete
device nodes, and it will not spawn commands. Instead, it will print to stdout
the actions it would have performed.
- -f conffile : read the configuration
file from conffile. Default is /etc/mdev.conf.
conffile must be an absolute path.
- -s slashsys : assume the sysfs
pseudo-filesystem is mounted on slashsys. Default is /sys.
slashsys must be an absolute path.
- -d slashdev : assume the device nodes
are to be found in slashdev. Default is /dev.
slashdev must be an absolute path.
- -F fwbase : assume the firmware files, if any,
are to be found in fwbase. Default is /lib/firmware.
fwbase must be an absolute path.
mdevd uses mdev's configuration file format.
A good mdev.conf example is available
If mdevd cannot find its configuration file, it will use a simple, basic default
configuration where it can create device nodes as root or delete them, and does
- The examples/ subdirectory of the mdevd package contains
examples on how to run mdevd under various init systems / supervisors. These
examples do not show how to run mdevd as a logged service, because mdevd
should normally be run early in the system's boot up sequence, before
mounting the disks - so the presence of a mounted partition suitable for
logging is not guaranteed. In normal use, mdevd is quite terse, so it
runs smoothly without a dedicated logger, with its error messages
going to the catch-all logger.