My *nix world

Finding which Linux module is needed for your hardware

Your Linux distro or even the stock Linux kernel comes with all thinkable drivers for all those hardware that they supported. Most of them are preselected by default (base on hardware architecture) to cover a wide palette of hardware.

However, if you are going to compile a Linux kernel only for your system, you should select/include only those modules that have something to do with your system. By cutting down the default kernel configuration you will save time, memory and will make your system faster.

How could you find out what drivers are need it by your system? Well, finding which Linux module is needed for your hardware is not that hard.

If you have already a functional system or if you can boot a Live Linux CD then all you have to do is to look into the Linux system filesystem (sysfs) and to determine which device is using what driver.

For instance, to determine what driver is my network card using, first I need to know the network interface (eq. eth0, wlan0, etc) I want to find what where does the symlink /sys/class/net//device/driver/module point to.

In my case if I run the command ls against the path specified earlier I get the relative path to the driver module for my network card (where =wlan1):

As you can see the driver needed by this device is called ath5k. To setup the kernel to include this driver all I have to do is to search a configuration parameter named CONFIG_%ATH5K% (where % means one or more characters).

You should not be surprised if you will find more than one parameter with the pattern shown above because there could hundreds devices from that vendor. For example, the following configuration parameters contain the pattern show earlier:


If you want to understand what means any of those drivers I suggest you to look them up on Linux Hardware Database (lhwdb.org). The query string for any kernel configuration parameter is:

Note: the CONFIG_ prefix in the example above is stripped, so if the kernel parameter is named CONFIG_parameter you should use only the parameter part in the lhwdb.org query (or just go to lhwdb.org and use the damn search box :o).

Ok, so you've found out what is the driver name for you network card, right? But there could be at least 10-20 different drivers and finally, just to determine the kernel configuration name you have to search the content of at least 1600 different kernel Makefiles. It could be done automatically, though:


The output of the code above run on my system looks like this (but it could look different on your system):

I searched on lhwdb.org and I've determined what represents each of these drivers and I've decided that those written with bold are the ones I need.

To include these and only these drivers on my Linux kernel, all I have to do is to step in each class of "Device drivers" (the lhwdb.org tells you even the kernel menus where to find these configuration parameters) and to select only those parameters that match with those shown by the output of the script above.

Final note: The method shown above it's just the tip of the iceberg since it covers the process of finding the core drivers for the system. In order to determine each tiny driver used by each tiny device you might have, I would recommend reading the "Linux kernel in a Nutshell" by Greg Kroah-Hartman, which presents more techniques regarding this topic.

Now, if you think that this article was interesting don't forget to rate it. It shows me that you care and thus I will continue write about these things.

 
The following two tabs change content below.
Finding which Linux module is needed for your hardware

Eugen Mihailescu

Founder/programmer/one-man-show at Cubique Software
Always looking to learn more about *nix world, about the fundamental concepts of math, physics, electronics. I am also passionate about programming, database and systems administration. 16+ yrs experience in IT projects.
Finding which Linux module is needed for your hardware

Latest posts by Eugen Mihailescu (see all)

Tagged on: , , ,

One thought on “Finding which Linux module is needed for your hardware

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Follow

Get every new post on this blog delivered to your Inbox.

Join other followers:

Optimization WordPress Plugins & Solutions by W3 EDGE