Linux see all drivers

Linux: How to find the device driver used for a device?

If my target has one device connected and many drivers for that device loaded, how can I understand what device is using which driver?

8 Answers 8

Example. I want to find the driver for my Ethernet card:

$ sudo lspci . 02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 01) $ find /sys | grep drivers.*02:00 /sys/bus/pci/drivers/r8169/0000:02:00.0 

First I need to find coordinates of the device using lspci ; then I find driver that is used for the devices with these coordinates.

I know the OP asked for «drivers being used», but what if the driver is not installed nor being used? How to find out just by the vendorID:productID ? Also, what if it is not a PCI device, and you only see it in lsusb for example?

@DrBeco: But if driver is not installed, what do you want to find? You should just google in this case

#!/bin/bash for f in /sys/class/net/*; do dev=$(basename $f) driver=$(readlink $f/device/driver/module) if [ $driver ]; then driver=$(basename $driver) fi addr=$(cat $f/address) operstate=$(cat $f/operstate) printf "%10s [%s]: %10s (%s)\n" "$dev" "$addr" "$driver" "$operstate" done 
$ ~/what_eth_drivers.sh eth0 [52:54:00:aa:bb:cc]: virtio_net (up) eth1 [52:54:00:dd:ee:ff]: virtio_net (up) eth2 [52:54:00:99:88:77]: virtio_net (up) lo [00:00:00:00:00:00]: (unknown) 

I’d like to find solution which would find also veth and other virtual drivers. IMHO the only solution is to use ethtool or lshw .

sudo lspci -v will show it. like this:

$ sudo lspci -v 00:01.0 VGA compatible controller: Advanced Micro Devices, Inc. . Kernel driver in use: radeon Kernel modules: radeon 

You can also combine it with grep like this:

$ sudo lspci -v | grep -A 20 VGA 

For USB based devices you can see the driver name by using the lsusb command:

And/or you use lshw which enumerates the devices on all buses including USB, PCI, etc so you can see which driver it uses:

FTR: the driver is shown at line titled configuration , for example: configuration: driver=btusb maxpower=100mA speed=12Mbit/s

If you just want to plainly use sysfs and doesn’t want to deal with all these commands which eventually looks inside sysfs anyways, here’s how:

say, what is the module/driver for eth6? «sfc» it is

# ls -l /sys/class/net/eth6/device/driver lrwxrwxrwx 1 root root 0 Jan 22 12:30 /sys/class/net/eth6/device/driver -> ../../../../bus/pci/drivers/sfc 

or better yet.. let readlink resolve the path for you.

# readlink -f /sys/class/net/eth6/device/driver /sys/bus/pci/drivers/sfc 

so. to figure out what are the drivers for all of your network interfaces:

# ls -1 /sys/class/net/ | grep -v lo | xargs -n1 -I<> bash -c 'echo -n <> :" " ; basename `readlink -f /sys/class/net/<>/device/driver`' eth0 : tg3 eth1 : tg3 eth10 : mlx4_core eth11 : mlx4_core eth2 : tg3 eth3 : tg3 eth4 : mlx4_core eth5 : mlx4_core eth6 : sfc eth7 : sfc eth8 : sfc eth9 : sfc 

Источник

Where to find a list of device drivers supported by linux?

I have read here that linux supports a large number of device drivers and by extension, it also supports a large number of devices connected via the USB port. Excerpt from that site:

Linux today supports more hardware devices than any other operating system in the history of the world. It does this using a development model significantly different from the familiar Windows device driver model.

Is there a list of all the different devices which are supported by linux ? and/or list of devices which are connected via USB and supported by linux`? This is different from just finding out which device drivers are currently supported in a given distribution by using the commands lsmod , lspci and dmesg | grep as the distribution providers only support few common drivers out of all the drivers supported by linux .

Читайте также:  Переименовать файл через консоль линукс

@MarkPlotnick, that is not what I meant. I meant, if a certain device is not supported by the kernel, should I then look for driver modules from the manufacturer of the device, or should I consider writing my own device driver? So, if there was a list, then it would help a developer know whether he has to write his own driver or if the kernel itself provided it

3 Answers 3

The lspci and lsusb commands just enumerates the devices connected to particular buses. They read id from the bus and use special file to map this ids to strings.

The lsmod showns just list of linux kernel modules. Linux kernel module is part of linux kernel code which is loaded dynamically — this modules are not necessary drivers, it may be just any part of the kernel code. This mechanism is used to save memory and boot time and do not load all code on boot, to make kernel development easier (you can unload/modify/load parts of the kernel). As the device driver is one of good applications of this dynamic loading — it is used in most drivers. The non-driver example is iptables (the network filtering mechanism) there only parts are loaded which are actually requested by user.

The dmesg is just a kernel text log — usually developer white something there in case of initialization, but this is entirely voluntary — so what you find there and which format is completely random.

Complete lists of the supported hardware is hard thing to get. Kernel consists of very different parts made by different people and there is a lot of similar devices with different labels.

Usually you can try to find if your device is supported on dedicated pages:

  • supported printers are on the linux printer database http://www.openprinting.org/printers
  • scanners are are sane page
  • video card on http://www.x.org/wiki/Projects/Drivers/
  • and so on

This is mainly because most things require not just kernel driver by also kind of userspace layer and there is kind of ‘project’ which does both parts with main interface in userspace.

Most advanced list of the supported may be extracted from kernel code — there is usually list of pci/usb ids supported for each particular drivers — there is a way to extract it: http://www.cyberciti.biz/tips/linux-find-supported-pci-hardware-drivers.html. But if you have kernel module which has an ID in the list doesn’t mean that device is fully supported or that you have userspace tools which allow you to use this module, or that this userspace tools exist in your particular distribution.

Читайте также:  Изменить цвет консоли линукс

Sometimes distribution vendors provide list of supported devices, but this is usually some small subset.

For debian there is also list of pciid->kernel module mappings: https://wiki.debian.org/DeviceDatabase/PCI.

Regarding usb devices, many things like cameras have kind of userspace drivers via libusb — like cameras or so no. In such case you have no need in kernel driver at all.

Also, don’t forget that linux runs on near 20 architectures (imagine how many drivers are in billions of different android smart-phones), each with own huge set of drivers — and you’ll see that total amount will easily beat every other knows OS.

Источник

How to get a list of active drivers that are statically built into the linux kernel?

While I can use lsmod in order to show currently active kernel modules, how can I see which drivers are statically built into the kernel AND currently active?

5 Answers 5

You could do a cat /lib/modules/$(uname -r)/modules.builtin

modules.builtin

This file lists all modules that are built into the kernel. This is used by modprobe to not fail when trying to load something builtin.

modules.builtin does not exist in my system with uname: Linux ecp 4.4.127-1.el6.elrepo.i686 #1 SMP Sun Apr 8 09:44:43 EDT 2018 i686 i686 i386 GNU/Linux. Is there another way to find what drivers are built in?

If your linux has a /proc/config.gz

That has all the built modules. Copy it elsewhere and unzip it. Open the file everything with a «=M» is built as a module. Everything with a «=Y» is statically built.

hwinfo will list the «Driver:» check the above file to see if it is statically built.

FYI: All statically built drivers are always loaded into memory and ready for action. Without the corresponding hardware they will not do anything, but use memory.

Ok I just found a .config file in the directory where I compiled the kernel, that’s obviously what you meant.

no need to unzip if you just want to see. Just zcat /boot/config-$(uname -r) or zcat /proc/config.gz . You can also use zgrep or zmore

The sysfs module area /sys/module is a view into all the modules visible to the running kernel. Each module directory has a set of sysfs interface files to view and manage the module via userspace. Generally speaking, the LKMs have a refcnt file, which will be greater than 0 if it is being used along with a holder directory of those modules using it. The builtin modules do not have this file (or many others like initstate and taint .)

Try find /sys/module -name refcnt -printf ‘\n%p: ‘ -exec cat <> \; to see which are being used.

Under many modules is a parameters directory containing the parameters that can be viewed and modified from user-space. In the source this is generally a call to a module_param macro. For example, see kernel/printk.c and the module /sys/module/printk/parameters for some useful printk tuning.

All entities under /sys/module are set in the kernel module framework. Some are hardware drivers, some are netfilter, some are filesystems, some debug, etc.

Источник

How to List Drivers in Linux

If you’re a Linux system administrator or power user, you may need to check which drivers are currently installed on your system. Fortunately, Linux provides several ways to list installed drivers. In this article, we’ll show you how to use command-line tools to list drivers on a Linux system. Understanding Drivers in Linux Before we […]

Читайте также:  Баш скрипт linux примеры

| Reader Disclosure Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission.

linux list drivers

If you’re a Linux system administrator or power user, you may need to check which drivers are currently installed on your system. Fortunately, Linux provides several ways to list installed drivers. In this article, we’ll show you how to use command-line tools to list drivers on a Linux system.

Understanding Drivers in Linux

Before we dive into how to list drivers in Linux, let’s take a moment to understand what drivers are and how they work.

In Linux, a driver is a software component that enables communication between the operating system and a hardware device. Without a driver, the operating system would not be able to control the device or access its features.

Linux drivers come in two flavors: kernel drivers and user-space drivers. Kernel drivers are part of the Linux kernel and are loaded at boot time. User-space drivers are loaded by user-space programs and run in user mode.

Using the lsmod Command

The lsmod command is a Linux utility that lists all currently loaded kernel modules, including drivers. To list all loaded drivers, open a terminal and type:

This command uses the grep utility to filter the output of lsmod to show only the kernel modules that start with «drm». The Direct Rendering Manager (DRM) is a subsystem of the Linux kernel responsible for managing graphics drivers.

You can also use the lsmod command without grep to list all loaded kernel modules, including drivers:

This command will display a list of kernel modules, including their names, sizes, and dependencies.

Using the modinfo Command

The modinfo command is another Linux utility that provides detailed information about a specific kernel module, including drivers. To use modinfo , open a terminal and type:

Replace with the name of the module you want to inspect. For example, to display information about the DRM kernel module, type:

This command will display information about the DRM module, including its description, author, license, and dependencies.

Using the lspci Command

The lspci command is a Linux utility that lists all PCI devices connected to the system, including their drivers. To list all PCI devices and their drivers, open a terminal and type:

This command uses the -k option to display the kernel driver that is currently in use by each PCI device.

Conclusion

In this article, we’ve shown you how to list drivers in Linux using command-line tools. The lsmod command lists all loaded kernel modules, including drivers. The modinfo command provides detailed information about a specific kernel module, including drivers. The lspci command lists all PCI devices connected to the system, including their drivers.

By understanding how to list drivers in Linux, you can better manage your system and troubleshoot issues related to hardware devices.

Alex Ivanovs

Alex is a full-stack developer with more than 15 years of experience. After many years of threading the self-taught path, he discovered a natural passion for writing. His past work includes helping build the Huffington Post Code column and working with publishers such as Entrepreneur, TheNextWeb, and many prominent tech startups.

Read also

Источник

Оцените статью
Adblock
detector