- How to find the driver (module) associated with a device on Linux?
- 4 Answers 4
- Update
- Detecting and categorizing device drivers in a running system
- 1 Answer 1
- How do I know what drivers are installed on Ubuntu?
- How do you check driver is installed or not?
- How do you check what drivers are installed Linux?
- How do I know if I have Nvidia drivers installed Ubuntu?
- How do I fix driver is not successfully installed?
- Why are my drivers not installing?
- Does Linux automatically find drivers?
- How do I list all drivers in Linux?
- Does Linux have a device manager?
- How do I get Nvidia drivers on Ubuntu?
- How do I install drivers on Ubuntu?
- How do I know which GPU is being used Ubuntu?
- What happens if a driver is not installed?
- How do I manually install a driver?
- How do I install device drivers?
- Find out which modules are associated with a usb device?
- 4 Answers 4
- Finding the Kernel Driver(s)
- The victim device
- Method 1: Using usbutils (easy)
- Method 2: Using debugfs (requires root)
- Method 3: Using only basic utilities to read /sys directly (best for scripting or recovery)
- What about userspace (usbfs) drivers?
- How do I find out what filesystem drivers are compiled-in into the linux kernel?
- 1 Answer 1
How to find the driver (module) associated with a device on Linux?
- a device, for example /dev/sda ,
- and its major and minor numbers, for example 8, 0 ,
how can I know which module / driver is «driving» it?
Can I dig into /sys or /proc to discover that?
4 Answers 4
To get this information from sysfs for a device file, first determine the major/minor number by looking at the output of ls -l , eg
The 8, 0 tells us that major number is 8 and the minor is 0 . The b at the start of the listing also tells us that it is a block device. Other devices may have a c for character device at the start.
If you then look under /sys/dev , you will see there are two directories. One called block and one called char . The no-brainer here is that these are for block and character devices respectively. Each device is then accessible by its major/minor number is this directory. If there is a driver available for the device, it can be found by reading the target of the driver link in this or the device sub-directory. Eg, for my /dev/sda I can simply do:
This shows that the sd driver is used for the device. If you are unsure if the device is a block or character device, in the shell you could simply replace this part with a * . This works just as well:
Block devices can also be accessed directly through their name via either /sys/block or /sys/class/block . Eg:
Note that the existence of various directories in /sys may change depending on the kernel configuration. Also not all devices have a device subfolder. For example, this is the case for partition device files like /dev/sda1 . Here you have to access the device for the whole disk (unfortunately there are no sys links for this).
A final thing which can be useful to do is to list the drivers for all devices for which they are available. For this you can use globs to select all the directories in which the driver links are present. Eg:
Finally, to diverge from the question a bit, I will add another /sys glob trick to get a much broader perspective on which drivers are being used by which devices (though not necessarily those with a device file):
Update
Looking more closely at the output of udevadm , it appears to work by finding the canonical /sys directory (as you would get if you dereferenced the major/minor directories above), then working its way up the directory tree, printing out any information that it finds. This way you get information about parent devices and any drivers they use as well.
To experiment with this I wrote the script below to walk up the directory tree and display information at each relevant level. udev seems to look for readable files at each level, with their names and contents being incorporated in ATTRS . Instead of doing this I display the contents of the uevent files at each level (seemingly the presence of this defines a distinct level rather than just a subdirectory). I also show the basename of any subsystem links I find and this showing how the device fits in this hierarchy. udevadm does not display the same information, so this is a nice complementary tool. The parent device information (eg PCI information) is also useful if you want to match the output of other tools like lshw to higher level devices.
Detecting and categorizing device drivers in a running system
How can I obtain what device drivers are incorporated in a running kernel?
More than this, how can I categorize these device drivers?
For instance, this is a Linux kernel conceptual map, from Wikipedia:
How can I distribute detected device drivers into correspondent area in the map above?
My impression is that such info could be obtained from kernel config files.
(I am not expecting answer to be in a graphical form. Textual categorization would suffice, but with the appropriate categories that can be, overall, matched to the areas in the picture.)
1 Answer 1
You can list the loaded drivers using lsmod. For example,
[root@vm bin]# lsmod Module Size Used by coretemp 13435 0 crc32_pclmul 13113 0 ghash_clmulni_intel 13259 0 aesni_intel 69884 0 lrw 13286 1 aesni_intel gf128mul 14951 1 lrw glue_helper 13990 1 aesni_intel ablk_helper 13597 1 aesni_intel cryptd 20359 3 ghash_clmulni_intel,aesni_intel,ablk_helper sg 40721 0 ppdev 17671 0 pcspkr 12718 0 vmw_balloon 13415 0 parport_pc 28165 0 parport 42348 2 ppdev,parport_pc vmw_vmci 67106 0 i2c_piix4 22106 0 shpchp 37032 0 ip_tables 27240 0 xfs 939662 3 libcrc32c 12644 1 xfs sr_mod 22416 0 cdrom 42556 1 sr_mod sd_mod 45497 3 crc_t10dif 12714 1 sd_mod ata_generic 12910 0 crct10dif_generic 12647 0 pata_acpi 13038 0 mptspi 22542 2 scsi_transport_spi 30732 1 mptspi mptscsih 40150 1 mptspi vmwgfx 176029 1 drm_kms_helper 125008 1 vmwgfx crct10dif_pclmul 14289 1 crct10dif_common 12595 3 crct10dif_pclmul,crct10dif_generic,crc_t10dif ttm 93441 1 vmwgfx crc32c_intel 22079 1 ata_piix 35038 0 drm 349210 4 ttm,drm_kms_helper,vmwgfx mptbase 105960 2 mptspi,mptscsih serio_raw 13462 0 libata 218730 3 pata_acpi,ata_generic,ata_piix vmxnet3 53833 0 i2c_core 40582 3 drm,i2c_piix4,drm_kms_helper floppy 69417 0 dm_mirror 22135 0 dm_region_hash 20862 1 dm_mirror dm_log 18411 2 dm_region_hash,dm_mirror dm_mod 113292 11 dm_log,dm_mirror
Then to further understand what each driver relates to, use modinfo
[root@vm bin]# modinfo coretemp filename: /lib/modules/3.10.0-327.el7.x86_64/kernel/drivers/hwmon/coretemp.ko license: GPL description: Intel Core temperature monitor author: Rudolf Marek rhelversion: 7.2 srcversion: 39EE385A7A807BDCB75C480 alias: x86cpu:vendor:0000:family:*:model:*:feature:*00E7* depends:
intree: Y vermagic: 3.10.0-327.el7.x86_64 SMP mod_unload modversions signer: CentOS Linux kernel signing key sig_key: 79:AD:88:6A:11:3C:A0:22:35:26:33:6C:0F:82:5B:8A:94:29:6A:B3 sig_hashalgo: sha256 parm: tjmax:TjMax value in degrees Celsius (int)
You then can use this info and categorize where each driver belongs to.
How do I know what drivers are installed on Ubuntu?
(Your device may be supported in Ubuntu with a native driver.) Use the lshw command. As explained under lshw, if there is a line saying configuration: … driver=… in the description of the wireless card, this indicates the driver is installed.
How do you check driver is installed or not?
How to determine driver version using Device Manager
- Open Start.
- Search for Device Manager and click the top result to open the experience.
- Expand the branch for the device that you want to check the driver version.
- Right-click the device and select the Properties option.
- Click the Driver tab.
How do you check what drivers are installed Linux?
Checking for the current version of driver in Linux is done by accessing a shell prompt.
- Select the Main Menu icon and click the option for “Programs.” Select the option for “System” and click the option for “Terminal.” This will open a Terminal Window or Shell Prompt.
- Type “$ lsmod” and then press the “Enter” key.
How do I know if I have Nvidia drivers installed Ubuntu?
By default, your integrated graphics card (Intel HD Graphics) is being used. Then open softare & updates program from you application menu. Click the additional drivers tab. You can see what driver is being used for Nvidia card (Nouveau by default) and a list of proprietary drivers.
How do I fix driver is not successfully installed?
Follow these steps to determine whether Device Manager can find the device and to install or reinstall the device driver as necessary:
- Step 1: Determine whether the device driver is found in Device Manager. Click Start. …
- Step 2: Uninstall and reinstall the device drivers. …
- Step 3: Use Windows Update to find a device driver.
Why are my drivers not installing?
A driver installation may fail for a number of reasons. Users may be running a program in the background that inteferes with the installation. If Windows is performing a background Windows Update, a driver installation may also fail.
Does Linux automatically find drivers?
Your Linux system should automatically detect your hardware and use the appropriate hardware drivers.
How do I list all drivers in Linux?
Under Linux use the file /proc/modules shows what kernel modules (drivers) are currently loaded into memory.
Does Linux have a device manager?
The “plug and play” manager of Linux is usually udev . udev is responsible for recognizing hardware changes, (possibly) autoloading modules, and creating nodes in /dev if needed.
How do I get Nvidia drivers on Ubuntu?
Ubuntu Linux Install Nvidia Driver
- Update your system running apt-get command.
- You can install Nvidia drivers either using GUI or CLI method.
- Open “Software and Updates” app to install install Nvidia driver using GUI.
- OR type “ sudo apt install nvidia-driver-455 ” at the CLI.
- Reboot the computer/laptop to load the drivers.
- Verify drivers are working.
How do I install drivers on Ubuntu?
Installing additional drivers in Ubuntu
- Step 1: Go to Software Settings. Go to the menu by pressing the Windows key. …
- Step 2: Check available additional drivers. Open the ‘Additional Drivers’ tab. …
- Step 3: Install the additional drivers. After the installation is complete, you will get a restart option.
How do I know which GPU is being used Ubuntu?
Ubuntu uses Intel graphics by default. If you think you made some changes to this before and you don’t remember what graphics card is being used, then go to system settings > details , and you will see the graphics card being used right now.
What happens if a driver is not installed?
What happens if a driver is not installed? If the appropriate driver is not installed, the device may not function properly, if at all. With some devices, the device may work, but all of its features may not work.
How do I manually install a driver?
This Article Applies to:
- Insert the adapter into your computer.
- Download the updated driver and extract it.
- Right click on Computer Icon, and then click Manage. …
- Open Device Manager. …
- Click Browse my computer for driver software.
- Click let me pick from a list of device drivers on my computer and click Next.
How do I install device drivers?
Install drivers using Device Manager
- Press Windows key + X.
- Click Device Manager.
- Once device manager is open, select the device, right click it and click Update Driver Software. This will launch the update driver software wizard, which presents two options:
Find out which modules are associated with a usb device?
Could you recommend a way to figure out which driver is being used for a USB device. Sort of a usb equivalent of lspci -k command.
4 Answers 4
Finding the Kernel Driver(s)
The victim device
We’re going to try to find out what driver is used for the APC UPS. Note that there are two answers to this question: The driver that the kernel would use, and the driver that is currently in use. Userspace can instruct the kernel to use a different driver (and in the case of my APC UPS, nut has).
Method 1: Using usbutils (easy)
The usbutils package (on Debian, at least) includes a script called usb-devices . If you run it, it outputs information about the devices on the system, including which driver is used:
Note that this lists the current driver, not the default one. There isn’t a way to find the default one.
Method 2: Using debugfs (requires root)
If you have debugfs mounted, the kernel maintains a file in the same format as usb-devices prints out at /sys/kernel/debug/usb/devices ; you can view with less , etc. Note that debugfs interfaces are not stable, so different kernel versions may print in a different format, or be missing the file entirely.
Once again, this only shows the current driver, not the default.
Method 3: Using only basic utilities to read /sys directly (best for scripting or recovery)
You can get the information out of /sys , thought its more painful than lspci . These /sys interfaces should be reasonably stable, so if you’re writing a shell script, this is probably how you want to do it.
Initially, lsusb seems to count devices from 1, /sys from 0. So 10-2 is a good guess for where to find the APC UPS lsusb gives as bus 10, device 3. Unfortunately, over time that mapping breaks down—sysfs re-uses numbers even when device numbers aren’t. The devnum file’s contents will match the device number given by lsusb, so you can do something like this:
So, in this case, it’s definitely 10-2 .
We can be sure this is the right device by cat ing a few of the files:
If you look in 10-2:1.0 ( :1 is the «configuration», .0 the interface—a single USB device can do multiple things, and have multiple drivers; lsusb -v will show these), there is a modalias file and a driver symlink:
So, the current driver is usbfs . You can find the default driver by asking modinfo about the modalias:
So, the APC UPS defaults to the hid driver, which is indeed correct. And its currently using usbfs, which is correct since nut ‘s usbhid-ups is monitoring it.
What about userspace (usbfs) drivers?
When the driver is usbfs , it basically means a userspace (non-kernel) program is functioning as the driver. Finding which program it is requires root (unless the program is running as your user) and is fairly easy: whichever program has the device file open.
We know that our «victim» device is bus 10, device 3. So the device file is /dev/bus/usb/010/003 (at least on a modern Debian), and lsof provides the answer:
And indeed, its usbhid-ups as expected (lsof truncated the command name to make the layout fit, if you need the full name, you can use ps 4951 to get it, or probably some lsof output formatting options).
How do I find out what filesystem drivers are compiled-in into the linux kernel?
On a running linux system, what is a portable (among linux distributions) way to find out what filesystems the current kernel has compiled-in (not through modules) support for?
Consider for example my current Ubuntu x86_64 kernel: 3.11.0-24-generic #41-Ubuntu . It has for instance no /proc/config.gz , which would be my first thought otherwise.
The reason I’m interested is that I’d like to (programmatically) build a rescue environment with the current kernel and an initial ramdisk that the kernel will be able to load/mount.
Is is as simple as comparing /proc/filesystems with lsmod ?
If so: Do the modules always have the exact same name (first column from lsmod output) as the filesystem name (last column in /proc/filesystems )?
Is there perhaps a more modern way such as /sys instead of /proc to look for info?
My current approach is as follows. Can someone confirm that it is correct, or advise how to do it instead?:
1 Answer 1
Is is as simple as comparing /proc/filesystems with lsmod ?
Many of these are not built into the kernel on that system. autofs is provided by a modules called autofs4 while nfs4 is provided by a module called nfs . The ext4 module provides ext2 and ext3 as well as ext4 ; fuse provides both fuseblk and fusectl . rpc_pipefs (not to be confused with pipefs ) is provided by sunrpc .