mdevd
mdevd -nandmdevd -Nallow dry runs and configuration file tests without actually runningmdevdmdevddeprecatess6-uevent-listenerands6-uevent-spawner- Check alpine’s patches
- Start
mdevdwith-O4; this will make the daemon rebroadcast kernel uevents tolibudev-zero - Readiness
-Donly works whenmdevdis being called bys6and not manually in aninitramfs - A summary of what
mdevd-coldplugandudevadm triggerdo:
for i in $(find /sys -name uevent); do ( echo change > $i ) ; done- There is no test suite
yashdoes not specifyPATHininitramfswhich causesmdevdto not find itscommands; this problem seems to not exist when usingdashmdev.confsyntax:
<device regex> <uid>:<gid> <permissions> [=path|>path|!] [@|$|*<command>]
- =path moves to path- >path symlinks device to path- ! prevents device from being created
- @ Run after creating the device.- $ Run before removing the device.- * Run both after creating and before removing the device.- The command is executed via the system() function (which means you’re giving a command to the shell), so make sure you have a shell installed at /bin/sh. You should also keep in mind that the kernel executes hotplug helpers with stdin, stdout, and stderr connected to /dev/null.
- Use libudev helper in
mdev.conf - Does
mdevdwork withudevdirectories and rules or should we delete them? devicesis the default value forudevadm trigger -t- with
udevadmyou have toudevadm hwdb --update
mdev.conf
Section titled “mdev.conf”mdevdparsesmdev.confwhen a new device event occurs/dev/audioand/dev/dsphave been replaced with newer drivers and naming conventions/dev/corehas been deprecated/dev/dspand/dev/adsphave been deprecated as modern systems don’t use OSS/dev/fd0has been deprecated/dev/grsechas been deprecated since4.14/dev/hd{a,b,c}have been deprecated/dev/hwrnghas replaced/dev/hwrandomand/dev/hw_random/dev/mixerand/dev/sequencerhave been deprecated as modern systems don’t use OSS/dev/psauxhas been deprecated/dev/ptyhas been deprecated since2.6.4(https://man7.org/linux/man-pages/man7/pty.7.html)/dev/sndhas replaced/dev/sound/dev/sr0has replaced/dev/cdrom/dev/sdahas replaced/dev/ccissand/dev/ida
udevd and libudev replacements criteria
Section titled “udevd and libudev replacements criteria”- handles ~10k devices (under one minute?)
- parallel processing (worker queues) and not linear processing
- cache
regcomp()results for speed in large device trees s6-uevent-listener(deprecated, seemdevd) provides standalone netlink monitoring- pipeline approach (listener > data gatherer > event dispatcher)
- each process replaceable if same api
- spawns per-event handlers (e.g.
mdevinstances) - use unix socket client-server model; single publisher, multiple subscribers
- implement filters server-side: dispatcher only links unfiltered events to client directories
- avoid dbus: simple client-server, not symmetrical peer messaging
- server-side filtering prevents unnecessary client wake-ups
- never lose events; filesystem storage ensures this
- filter at kernel/server level when possible
- maintain replaceable components
- avoid technical debt of message bus dependencies
libudev:udev_monitor_set_receive_buffer_size()irrelevant for filesystems as events persist- inefficient client-side filtering; wakes process for filtered events
- current socketpair emulation loses filesystem advantage (events can be lost)
References
Section titled “References”- https://codeberg.org/emmett1/alicelinux/src/branch/main/repos/core/busybox/mdev.conf
- https://codeberg.org/kiss-community/repo/src/branch/master/core/busybox/files/mdev.conf
- https://codeberg.org/smj/mdevd-as-an-admin
- https://git.busybox.net/busybox/plain/docs/mdev.txt
- https://github.com/AlexRogalskiy/aports/blob/master/main/busybox-initscripts/mdev.conf
- https://github.com/eweOS/packages/blob/busybox/mdev.conf
- https://github.com/fff7d1bc/mdev-like-a-boss/blob/master/mdev.conf
- https://github.com/illiliti/libudev-zero/blob/master/contrib/mdev.conf
- https://github.com/skarnet/mdevd/issues/10#issuecomment-2611158482
- https://gitlab.alpinelinux.org/alpine/mdev-conf/-/blob/master/mdev.conf.in
- https://wiki.archlinux.org/title/Udev
- https://wiki.gentoo.org/wiki/Mdev
- https://wiki.gentoo.org/wiki/Mdev/Automount_USB
- https://wiki.gentoo.org/wiki/Mdev/Automount_USB/automount
- https://www.linuxfromscratch.org/lfs/view/development/chapter08/udev.html
- https://youtube.com/watch?v=k_TGPNN7QY0
- https://youtube.com/watch?v=xhfEET46sGA