How to install kernel modules automatically after device insertion
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to install kernel modules automatically after device insertion
ubuntu could delay kernel module installation until device is inserted?
Take my usb ath9271 wifi adapter as an example:
when kernel boot up, no ath modules are installed
until usb wifi apdapter is inserted, ath related modules are insmod.
Could anybody how to achieve this? udev or something else?
UDEV can be used to load kernel modules upon device insertion, or anything else you want, for that matter. Each UDEV rule has a "RUN" parameter that lets you enter in a command for the system to run. It could load a module, play a noise, put a notification on the screen, etc.
There are many guides online for writing UDEV rules, but I liked the one published by HackADay awhile ago, as that gives a pretty clear explanation and practical example:
UDEV can be used to load kernel modules upon device insertion, or anything else you want, for that matter. Each UDEV rule has a "RUN" parameter that lets you enter in a command for the system to run. It could load a module, play a noise, put a notification on the screen, etc.
There are many guides online for writing UDEV rules, but I liked the one published by HackADay awhile ago, as that gives a pretty clear explanation and practical example:
Does it work as the following steps?
1. ath721N usb wifi adapter is inserted
2. udev gets usb device information
3. udev searches rule to find ath721N driver and install it
I have looked into /etc/udev/rules.d/* and /etc/modprobe.d/*, but didn't find any special entries for USB devices.
Is there any other places for the rules?
Will it search /lib/modules/2.6.xx/modules.usbmap?
# See if there is already some information available when you insert it
dmesg | head -n 20
# See what information is available to udev
/sbin/udevadm info --query=all [--name=<device path>] [--path=<sysfs path>]
# or query the whole database of devices plugged into udev and export it to a file
/sbin/udevadm info --export-db > /path/to/export.txt
Along with a udev tutorial, that should be enough to help you.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.