Linux find drivers in use

Как узнать какой драйвер использует устройство в Ubuntu Linux

Пункт Kernel driver in use.

Как узнать какой драйвер использует устройство в Ubuntu Linux: 6 комментариев

Вася, добавил в исходную заметку картинку, чтобы было понятно что нужно смотреть. Таким образом мы узнаём [b]какой именно драйвер[/b] (правильно всё-таки его называть модулем) использует Linux для устройства. Я не очень понимаю зачем нужна [b]именно версия драйвера[/b], так как она жёстка привязана к версии ядра и обычно для железа говорят, что оно поддерживается, начиная с такой-то версии ядра. Видимо это наследие M$. Если хотите узнать версию ядра, то в терминале нужно выполнить ( $ в начале строки означает, что команда вводится от обычного пользователя и не вводится в терминал. Со второй строки идёт результат выполнения команды. ) :

$ uname -a Linux asus 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

[i]4.15.0-96-generic[/i] и есть версия ядра. Если очень хочется узнать версию модуля, то можно узнать md4-хэш от исходников, использованных для компиляции модуля:

$ modinfo iwlwifi | grep -E '^(src|)version' srcversion: 85B6BF2737FFC0E2C190EE5

Поле version у некоторых модулей тоже присутствует, но редко. Правда, я не знаю для чего может понадобится эта информация.

Версия драйвера важна для видеодрайвера. Тут можно узнать, что для карточки используется драйвер nvidia, а версии нет.

Не забываем, что если устройство работает, то используется модуль, который поддерживает устройство. В случае с проприетарными модулями lspci -v покажет, что используется проприетарный модуль и какой именно. Относительно NVIDIA это должно быть что-то типа (проверить не могу, так как нет доступа к устройству с картой от NVIDIA): nvidia.ko Соответственно, версию нужно уже искать в самом проприетарном модуле:
# modinfo /usr/lib/modules/$(uname -r)/kernel/drivers/video/nvidia.ko | grep ^version
или
# find /usr/lib/modules -name nvidia.ko -exec modinfo <> \; Источник.

Добавить комментарий Отменить ответ

Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.

Источник

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?

Читайте также:  Linux security limit conf

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 

Источник

Читайте также:  Линукс операционная система совместимость

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.

Читайте также:  Composer php установка linux

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 Find the Device Driver Used for a Device in Linux?

The device drivers are the software packages having no user interface that manage and control the system hardware devices. The external and internal devices require the drivers because they build up the connection between the device and the operating system. If the driver of a specific device is not installed, it can not work properly.

Keeping this in view, this article lists all possible ways to find the device drivers used for a device in Linux:

Method 1: Using “modinfo” Command

The “modinfo” command displays the Linux kernel modules/drivers information. It returns the list of all the modules/drivers in the terminal without passing any argument.

To get the particular device driver information, specify the device name with it as follows:

The “e1000” device driver detail has been displayed in the output.

Method 2: Using “lsusb” Command(For USB Device)

The “lsusb” command is the built-in command line tool that lists down the USB device information connected to the system. It also provides the driver details that are installed for it. Let’s see how this command displays the USB device drivers.

Execute the “lsusb” command followed by the “-t(tree format)” flag to get the “usb” device drivers:

The above command has displayed the “usb” device busses and drivers in the terminal.

Conclusion

In Linux, to find the specific device drivers use the “modinfo” command with the particular device name. Apart from other hardware devices, the user can use the “lsusb” command only to get the USB device driver details.

This article has covered all possible ways to find the device driver used for a device in Linux.

Источник

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