busybox: mdev: make mdev auto load modules at boot
PATCH 1/1 busybox: mdev: make mdev auto load modules at boot
Thanks to the MODALIAS line at the beginning of mdev.conf, mdev supports module auto probing on hotplug.
However, this does not work for cold plugged modules (i.e. modules for devices that were probed before mdev is added as hotplug handler). Running mdev -s to replay hotplug events does not work in that case.
Let's manually modprobe all modules in the rootfs.
Taken from:
- https://github.com/buildroot/buildroot/commit/07f46c2b6daec44a6176039c90be67e66c4c2e42
- https://github.com/buildroot/buildroot/commit/b4fc5a180c81689a982d5c595844331684c14f51
We need xargs to support zero termination of args so let's enable this configuration in the fragment for mdev.
--- meta/recipes-core/busybox/busybox/mdev.cfg | 2 ++ meta/recipes-core/busybox/files/mdev | 1 + 2 files changed, 3 insertions(+)
meta/recipes-core/busybox/busybox/mdev.cfg +2 -0
@@ -9,3 +9,5 @@ CONFIG_SETSID=y CONFIG_CTTYHACK=y CONFIG_FEATURE_SHADOWPASSWDS=y + +CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y
meta/recipes-core/busybox/files/mdev +1 -0
@@ -9,6 +9,7 @@ touch /dev/mdev.seq #sysctl -w kernel.hotplug=/sbin/mdev echo "/sbin/mdev" > /proc/sys/kernel/hotplug mdev -s +find /sys/ -name modalias -print0 | xargs -0 sort -u -z | xargs -0 modprobe -abq # # We might have mounted something over /dev, see if /dev/initctl is there.
Signature · 1 line
2.14.1
Quoted 37 lines · Quentin Schulz
Thanks to the MODALIAS line at the beginning of mdev.conf, mdev supports module auto probing on hotplug.
However, this does not work for cold plugged modules (i.e. modules for devices that were probed before mdev is added as hotplug handler). Running mdev -s to replay hotplug events does not work in that case.
Let's manually modprobe all modules in the rootfs.
Taken from:
- https://github.com/buildroot/buildroot/commit/07f46c2b6daec44a6176039c90be67e66c4c2e42
- https://github.com/buildroot/buildroot/commit/b4fc5a180c81689a982d5c595844331684c14f51We need xargs to support zero termination of args so let's enable this configuration in the fragment for mdev.
Signed-off-by Quentin Schulz <[email protected]>--- meta/recipes-core/busybox/busybox/mdev.cfg | 2 ++ meta/recipes-core/busybox/files/mdev | 1 + 2 files changed, 3 insertions(+)meta/recipes-core/busybox/busybox/mdev.cfg +2
-0@@ -9,3 +9,5 @@ CONFIG_SETSID=y CONFIG_CTTYHACK=y CONFIG_FEATURE_SHADOWPASSWDS=y + +CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=ymeta/recipes-core/busybox/files/mdev +0
-0
meta/recipes-core/busybox/files/mdev touch /dev/mdev.seq · line 13
Quoted 5 lines
meta/recipes-core/busybox/files/mdev +1
-0@@ -9,6 +9,7 @@ touch /dev/mdev.seq #sysctl -w kernel.hotplug=/sbin/mdev echo "/sbin/mdev" > /proc/sys/kernel/hotplug mdev -s +find /sys/ -name modalias -print0 | xargs -0 sort -u -z | xargs -0 modprobe -abq
will this execute on every boot ?
Hi,
Quoted 31 lines · Khem Raj
Quoted 29 lines · Quentin Schulz
Thanks to the MODALIAS line at the beginning of mdev.conf, mdev supports module auto probing on hotplug.
However, this does not work for cold plugged modules (i.e. modules for devices that were probed before mdev is added as hotplug handler). Running mdev -s to replay hotplug events does not work in that case.
Let's manually modprobe all modules in the rootfs.
Taken from:
- https://github.com/buildroot/buildroot/commit/07f46c2b6daec44a6176039c90be67e66c4c2e42
- https://github.com/buildroot/buildroot/commit/b4fc5a180c81689a982d5c595844331684c14f51We need xargs to support zero termination of args so let's enable this configuration in the fragment for mdev.
Signed-off-by Quentin Schulz <[email protected]>--- meta/recipes-core/busybox/busybox/mdev.cfg | 2 ++ meta/recipes-core/busybox/files/mdev | 1 + 2 files changed, 3 insertions(+)meta/recipes-core/busybox/busybox/mdev.cfg +0
-0@@ -9,3 +9,5 @@ CONFIG_SETSID=y CONFIG_CTTYHACK=y
Quoted 15 lines
meta/recipes-core/busybox/files/mdev touch /dev/mdev.seq · line 13
Quoted 13 lines
meta/recipes-core/busybox/busybox/mdev.cfg +2
-0CONFIG_FEATURE_SHADOWPASSWDS=y + +CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=ymeta/recipes-core/busybox/files/mdev +1
-0@@ -9,6 +9,7 @@ touch /dev/mdev.seq #sysctl -w kernel.hotplug=/sbin/mdev echo "/sbin/mdev" > /proc/sys/kernel/hotplug mdev -s +find /sys/ -name modalias -print0 | xargs -0 sort -u -z | xargs -0 modprobe -abqwill this execute on every boot ?
This file is installed to /etc/init.d[1] and since this recipe inherits update-rc.d[2] which takes care of adding those links to /etc/rcN.d/, yes, it is executed at each boot.
I've also tested this patch since I need it for a USB controller driver module and, in practical, it does get executed at each boot.
[1] http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-core/busybox/busybox.inc#n303
[2] http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-core/busybox/busybox.inc#n53
Quentin
Quoted 6 lines · Quentin Schulz
Thanks to the MODALIAS line at the beginning of mdev.conf, mdev supports module auto probing on hotplug.
However, this does not work for cold plugged modules (i.e. modules for devices that were probed before mdev is added as hotplug handler). Running mdev -s to replay hotplug events does not work in that case.
I'd rather have this in a seperate bootscript, like this (which performs the same but applies a filter):
https://github.com/topic-embedded-products/meta-topic/tree/master/recipes-core/module-init-tools
This gives users a choice as to whether or not they want this to happen.
Another note: Since this runs at each and every boot, it'd be wise to optimize this for performance. That "sort -u" might be bad for performance, and modprobe doesn't mind if modules were already probed.
Quoted 31 lines
Let's manually modprobe all modules in the rootfs.
Taken from:
- https://github.com/buildroot/buildroot/commit/07f46c2b6daec44a6176039c90be67e66c4c2e42
- https://github.com/buildroot/buildroot/commit/b4fc5a180c81689a982d5c595844331684c14f51We need xargs to support zero termination of args so let's enable this configuration in the fragment for mdev.
Signed-off-by Quentin Schulz <[email protected]>--- meta/recipes-core/busybox/busybox/mdev.cfg | 2 ++ meta/recipes-core/busybox/files/mdev | 1 + 2 files changed, 3 insertions(+)meta/recipes-core/busybox/busybox/mdev.cfg +2
-0@@ -9,3 +9,5 @@ CONFIG_SETSID=y CONFIG_CTTYHACK=y CONFIG_FEATURE_SHADOWPASSWDS=y + +CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=ymeta/recipes-core/busybox/files/mdev +0
-0
meta/recipes-core/busybox/files/mdev touch /dev/mdev.seq · line 15
Quoted 7 lines
meta/recipes-core/busybox/files/mdev +1
-0@@ -9,6 +9,7 @@ touch /dev/mdev.seq #sysctl -w kernel.hotplug=/sbin/mdev echo "/sbin/mdev" > /proc/sys/kernel/hotplug mdev -s +find /sys/ -name modalias -print0 | xargs -0 sort -u -z | xargs -0 modprobe -abq # # We might have mounted something over /dev, see if /dev/initctl is there.
Kind regards,
Mike Looijmans
System Expert
TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: [email protected]
Website: www.topicproducts.com
Please consider the environment before printing this e-mail
Quoted 8 lines · Mike Looijmans
Quoted 6 lines · Quentin Schulz
Thanks to the MODALIAS line at the beginning of mdev.conf, mdev supports module auto probing on hotplug.
However, this does not work for cold plugged modules (i.e. modules for devices that were probed before mdev is added as hotplug handler). Running mdev -s to replay hotplug events does not work in that case.
Quoted 6 lines
I'd rather have this in a seperate bootscript, like this (which performs the same but applies a filter):
https://github.com/topic-embedded-products/meta-topic/tree/master/recipes-core/module-init-toolsThis gives users a choice as to whether or not they want this to happen.
Well, this is a matter of expectations, I really think that final users will expect that by default modules will be automatically loaded at boot time. Wanting modules to be loaded automatically by the hotplug events and not at boot time is a really specific use case.
Advanced users will still have the choice to use a different init script if they don't want that to happen.
Quoted 66 lines
Another note: Since this runs at each and every boot, it'd be wise to optimize this for performance. That "sort -u" might be bad for performance, and modprobe doesn't mind if modules were already probed.
Quoted 29 lines
Let's manually modprobe all modules in the rootfs.
Taken from:
- https://github.com/buildroot/buildroot/commit/07f46c2b6daec44a6176039c90be67e66c4c2e42
- https://github.com/buildroot/buildroot/commit/b4fc5a180c81689a982d5c595844331684c14f51We need xargs to support zero termination of args so let's enable this configuration in the fragment for mdev.
Signed-off-by Quentin Schulz <[email protected]>--- meta/recipes-core/busybox/busybox/mdev.cfg | 2 ++ meta/recipes-core/busybox/files/mdev | 1 + 2 files changed, 3 insertions(+)meta/recipes-core/busybox/busybox/mdev.cfg +2
-0@@ -9,3 +9,5 @@ CONFIG_SETSID=y CONFIG_CTTYHACK=y CONFIG_FEATURE_SHADOWPASSWDS=y + +CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=ymeta/recipes-core/busybox/files/mdev +0
-0meta/recipes-core/busybox/files/mdev touch /dev/mdev.seq · line 15
Quoted 7 lines
meta/recipes-core/busybox/files/mdev +1
-0@@ -9,6 +9,7 @@ touch /dev/mdev.seq #sysctl -w kernel.hotplug=/sbin/mdev echo "/sbin/mdev" > /proc/sys/kernel/hotplug mdev -s +find /sys/ -name modalias -print0 | xargs -0 sort -u -z | xargs -0 modprobe -abq # # We might have mounted something over /dev, see if /dev/initctl is there.Kind regards,
Mike Looijmans
System ExpertTOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: [email protected]
Website: www.topicproducts.comPlease consider the environment before printing this e-mail
Signature · 4 lines
_______________________________________________ Openembedded-core mailing list [email protected] http://lists.openembedded.org/mailman/listinfo/openembedded-core
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com