LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   How to install kernel modules automatically after device insertion (http://www.linuxquestions.org/questions/programming-9/how-to-install-kernel-modules-automatically-after-device-insertion-857072/)

neversetsun 01-18-2011 12:17 PM

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?

Thanks!

Snark1994 01-18-2011 03:47 PM

Googling for "ubuntu load module when usb inserted" found me this as the first result: http://www.linuxquestions.org/questi...insert-843842/

corp769 01-18-2011 03:56 PM

snark, thanks for that link man. definitely going to help me out tonight with my alfa wireless dongle.....

MS3FGX 01-18-2011 03:58 PM

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:

HackADay.com - How to write udev rules

neversetsun 01-19-2011 09:00 AM

Quote:

Originally Posted by MS3FGX (Post 4229245)
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:

HackADay.com - How to write udev rules

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?

lumak 01-19-2011 10:29 AM

Code:

# 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.


All times are GMT -5. The time now is 07:21 AM.