LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-18-2011, 12:17 PM   #1
neversetsun
LQ Newbie
 
Registered: Feb 2009
Posts: 5

Rep: Reputation: 0
Post 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!
 
Old 01-18-2011, 03:47 PM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,630
Blog Entries: 3

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
Googling for "ubuntu load module when usb inserted" found me this as the first result: http://www.linuxquestions.org/questi...insert-843842/
 
Old 01-18-2011, 03:56 PM   #3
corp769
Guru
 
Registered: Apr 2005
Posts: 5,807

Rep: Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996Reputation: 996
snark, thanks for that link man. definitely going to help me out tonight with my alfa wireless dongle.....
 
Old 01-18-2011, 03:58 PM   #4
MS3FGX
Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
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
 
Old 01-19-2011, 09:00 AM   #5
neversetsun
LQ Newbie
 
Registered: Feb 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by MS3FGX View Post
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?
 
Old 01-19-2011, 10:29 AM   #6
lumak
Member
 
Registered: Aug 2008
Location: Phoenix
Distribution: Arch
Posts: 799
Blog Entries: 32

Rep: Reputation: 109Reputation: 109
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.
 
  


Reply

Tags
driver


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Delayed insertion of Kernel modules possible? JZL240I-U Linux - Kernel 2 06-03-2010 05:06 AM
Creation of device node after USB insertion paldebojyoti Linux - Distributions 6 08-20-2009 06:01 AM
how can insertion of one module deletes other modules iamjayanth Linux - Newbie 3 10-31-2008 11:36 PM
Compiling a custom kernel, automatically remove unused modules ? sauce Linux - Kernel 1 01-29-2008 12:20 AM
Some modules don't get automatically loaded after kernel upgrade redleafong Linux - Software 4 05-21-2006 01:43 PM


All times are GMT -5. The time now is 03:27 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration