Speedup udev
From ArchWiki
i18n |
---|
English |
Contents |
Introduction
This article applies to stock Arch kernels.
The "Loading UDev uevents" takes up some time in the boot process. I was able to speed it up from 11.5 sec to 5.5 sec (udev-116).
The new udev-118 package does not only contain the new udev binairies, but also optimized scripts. (The hack will improve boottime, but only from 4sec to 3.5sec. (The script optimalisation is based on no blacklisted modules in rc.conf).
If you don't use MOD_AUTOLOAD="yes" this hack will have no effect.
If you rely on blacklisting certain modules, this hack is not for you. unless you're lucky and the /etc/modprobe.conf approach works.
Caution
This hack could corrupt the boot process and stop your pc from booting properly. If you have no idea what this hack is doing, i suggest you don't apply it.
USE IT AT YOUR OWN RISK
How it works
The /lib/udev/load-modules.sh script contains logic for blacklisting certain modules. This script is well written, but because this script runs for every module it slows down the boot process.
Option 1
If you replace the /lib/udev/load-modules.sh (create a backup first) with this:
#! /bin/sh /sbin/modprobe $1
As you can see the script contains no blacklisting logic whatsoever, so it runs faster, but the rules in /etc/rc.conf don't work anymore. If you don't have any module blacklisted, you're done. (You will have to repeat this hack when you install a new version of udev)
Option 2
Its even faster if you skip the shell script and directly call modprobe.
replace all "/lib/udev/load-modules.sh" to "/sbin/modprobe" in /etc/udev/*.rules
sed -i "s#/lib/udev/load-modules.sh#/sbin/modprobe#g" /etc/udev/rules.d/*.rules
To revert to the old configuration, do:
sed -i "s#/sbin/modprobe#/lib/udev/load-modules.sh#g" /etc/udev/rules.d/*.rules
Option 3
Similar to Option 2, above, but just replace "/lib/udev/load-modules.sh" with a symlink to "/sbin/modprobe".
Blacklisting modules
Because the hack ignores the MODULES=() and MOD_BLACKLIST=() we need an other way to prevent modules from loading.
/etc/modprobe.conf can help. Add a line for every module you want blacklisted.
blacklist foo blacklist bar
Beware this doesn't always work. As phrakture pointed out:
modprobe.conf blacklisting is not the same as the way we do it. It will actually not work at all. Here's why: modprobe's "blacklist" option blacklists modules loaded by that name and that name only. "modprobe foo" will not load foo. However, if some module "foo2" also depends on foo, "modprobe foo2" will still load foo because blacklisting does not match dependent modules. That's the whole reason we did blacklisting the way we did.