Check driver loaded linux

How to determine if a specific module is loaded in linux kernel

I am just curious is there any way to determine if a particular module is loaded/installed. $ lsmod lists all modules (device driver loaded). Is there any way to check or a command that returns true/false boolean output if a module name is polled. For eg. if keyboard.o exists return true else false. I need this tip to complete my driver auto refresh program. PS: tried modinfo. I am using busybox client in my test DUT so can you give some alternatives other than modinfo?

The question is a bit ambiguous. Are you trying to check if the driver is loaded into memory or installed on the system? modinfo would help with the latter but not the former.

10 Answers 10

The modinfo module method does not work well for me. I prefer this method that is similar to the alternative method proposed:

#!/bin/sh MODULE="$1" if lsmod | grep -wq "$MODULE"; then echo "$MODULE is loaded!" exit 0 else echo "$MODULE is not loaded!" exit 1 fi 

not sure if modinfo modname and checking $? will work for you, just a suggestion.

/tmp$ sudo modinfo e1000 /tmp$ echo $? 0 /tmp$ sudo modinfo keyboard ERROR: modinfo: could not find module keyboard /tmp$ echo $? 1 

alternatively you also grep /proc/modules

Just a note: the modinfo approach doesn’t seem to actually work for the loaded check (as in the question title). It shows info regardless of whether the module is loaded.

This is not a good solution. modinfo shows information of a kernel module installed on the rootfs, but it doesn’t check if the module is loaded into the kernel or not. So this solution should not be used to solve the issue.

The —first-time flag causes modprobe to fail if the module is already loaded. That in conjunction with the —dry-run (or the shorthand -n ) flag makes a nice test:

modprobe -n --first-time $MODULE && echo "Not loaded" || echo "Loaded" 

Edit 1: As @Nobody pointed out this also prints Loaded if the module does not exist. We can fix this by combining it with modinfo :

modinfo $MODULE >/dev/null 2>/dev/null && ! modprobe -n --first-time $MODULE 2>/dev/null && echo "Loaded" || echo "Not loaded" 

Edit 2: On some systems modprobe lives in /usr/sbin , which is not in the $PATH unless you are root. In that case you have to substitute modprobe for /usr/sbin/modprobe in the above.

Читайте также:  Удалить docker linux mint

Oh, sorry, I was only half-right (or maybe quarter-right. Shame on you comment-up-voters). On Debian, modprobe is not in $PATH for normal users, so just copy&pasting your command only works as root. But when calling modprobe with its full path, it’s executable for normal users and only the actual inserting operation fails, so your solution works in principle. I still think querying /proc/modules is more elegant, but that’s a matter of taste. Had I downvoted your answer, I would have removed the vote now (but I didn’t).

MODULE=snd_aloop # for example test -n "$(grep -e "^$MODULE " /proc/modules)" && echo "Loaded" || echo "Not loaded" 

It checks in /proc/modules . If the module is mentioned there, it’s assumed to be loaded, otherwise not.

The others seemed too long to me (the other short one requires root, this does not). Of course it’s just written out what was already mentioned as «alternatives».

Caution: modprobe accepts some variants of module names other than the primary listed in /proc/modules . For example loading snd-aloop works, but the module is named snd_aloop and is listed as such in /proc/modules and when using rmmod that’s also the only name that will work.

Источник

Introduction

This part of the guide is designed to help you troubleshoot your wireless adpater’s driver issues. This page is part of the WirelessTroubleShootingGuide. You should have correctly identified your device as detailed in the Devices page of this guide. See also the comprehensive explanations of commands for troubleshooting your wireless.

1. Check for Loaded Device Drivers

IconsPage/question.png

First you should check if a driver automatically loaded. (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.

If you are not running the most recent kernel, update your system (System > Administration > Update Manager). Drivers, especially wireless, are constantly being added and modified.

2. Choosing, Finding and Installing Drivers

2.1. Using Native Linux Drivers

  • Check in System > Administration > Hardware Drivers for a binary driver. For instance, many Broadcom cards will work with the Broadcom STA driver. Unfortunately, the driver is proprietary (the source code is not freely available), and so cannot be installed automatically as part of Ubuntu. If you are willing to accept this limitation, activate the driver.
  • Search your card manufacturer’s website for a Linux driver.

2.2. Using ndiswrapper for Cards Without a Linux Driver

  • You can check here to see if your card is supported by ndiswrapper.
  • full information on ndiswrapper kept on this page including troubleshooting help specific to ndiswrapper.
  • There may be a native driver that comes with Ubuntu which is conflicting with ndiswrapper. In such cases, if you want to use ndiswrapper, you can blacklist the native driver. See below for details.
Читайте также:  Настройка серверов linux ftp настройки

3. Check Driver

  1. Run the command lsmod to see if driver is loaded. (look for the driver name that was listed in the output of lshw, «configuration» line).
    • If you did not see the driver module in the list then use the modprobe command to load it.
    • If you see two modules (usually ndiswrapper and a native Linux driver) blacklist one of them (see below).
  2. run the command sudo iwconfig. If you see output like in the example in the command section then the driver is at least identifying the device as a wireless device to the kernel.
    • Opening networking in system>administration> and seeing the device in the list is how to identify through a gui if the driver is at least communicating with the kernel.
  3. run the command sudo iwlist scan to scan for a router. If an access point is identified this shows that the card is probably working properly as it can complete a wireless interface task. (note not all cards support scanning)

3.1. Multiple drivers loaded

For some cards (e.g., SMC2632W v1.02), an additional set of drivers is incorrectly loaded, effectively disabling wireless networking by generating two apparent wifi cards where there should only be one. Typically, you’ll see entries for both eth1 and wlan0_rename after running the iwconfig command, with your communication speed divided evenly between them. One of those drivers should not be loaded, and should be blacklisted. To do so, edit /etc/modprobe.d/blacklist and add the following lines:

where is, for example, «hostap» (the «hostap» driver apparently causes problems for several cards). Then save, reboot, and check your connection with iwconfig.

3.2. Driver looks ok, device disabled

Newer laptops come with battery saving features to disable the wireless radio. Usually this is switched by a FN+Fx key combo or a specific button for the purpose. It is possible the driver and connection is ok but the wireless device is disabled and can’t be used. Using the designated key(s) in linux sometimes does not work.

  1. rfkill list will show if there is a hardware or software block.
  2. lshw command you see *-network:1 DISABLED or wireless=radio off
  3. If you run the iwconfig command you see eth1 NOT READY!.
  1. Look at the LaptopTestingTeam page on the team wiki to see if your laptop is listed with any information.
  2. Do a google search using terms such as manufacture, model, linux, wireless, enable, button, radio. etc. When searching and finding similar pages that don’t help, use words that are used in those pages to help you search.
  3. Go to the ubuntu forums or ask ubuntu and ask, maybe someone else has the same laptop and knows the work around.
  4. Some laptops have a controller chip on the motherboard that is only accessible through a different OS. If you have turned off your wireless adapter in a different operating system, you may have to boot back into that OS and enable the card before it is accessible to Linux.
Читайте также:  Run bash file linux

WifiDocs/WirelessTroubleShootingGuide/Drivers (последним исправлял пользователь lnee 2022-04-28 22:40:30)

The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details

Источник

How do I check the status of my drivers and install them if needed? [duplicate]

I’m trying to learn how to use Ubuntu, but I must say I didn’t have half as many issues with 16 as I have had with 18.04 I’m using a laptop and I’m at a beginner-level. (But I’m willing to learn) And basically I’m having a lot of lag, and perhaps I don’t have the correct drivers. I’d need an easy command to pull up my system info, and then run a check on my drivers and download what’s needed. Proc: AMD e1-1200 APU with Radeon HD graphics x2, Mem: 3.5m total, 1.7g used, 651m free, Swap: 3.6g total, 29m used, 3.6g free CPU MHz: 778.147, CPU max MHz: 1400.0000, CPU min MHz: 777.0000

You’re thinking of apps that run in the Windows environment. I’m not aware of anything similar in the Ubuntu/Linux environment. Maybe, describe more about your «lag» and we might come up with some ideas on how to cure that. Does the lag happen all of the time? Only in one app? When you’re running a VPN? Etc.

I’ll have to read more about the kernal system and the major differences between Linux and Windows, to better understand. But basically, my system is very slow upon installing ubuntu 18.04. Namely, application windows slowly opening, webpages and while trying to play Minecraft. Generally the entire system seems slow.

What processor? What speed? How much RAM/swap? What video subsystem/drivers? Edit your question to show me free -h .

3 Answers 3

This has been answered before but in two parts.

First displaying loaded kernel modules.

Linux (and Ubuntu as well) doesn’t have separate entity as «device drivers», Linux has kernel modules which could be called «drivers» for real or virtual hardware depending on their functionality.

Use lsmod or cat /proc/modules to see list of loaded kernel modules. Also you can see list of all available (installed) kernel modules in system using:

ls -R /lib/modules/`uname -r`/kernel/ 

Next, using Software Sources > Additional Drivers, for installing device drivers, often proprietary.

Unity (15.10 and 15.04/14.04/13.04/14.10/13.10/12.10)

Click on the gear icon on the top right corner of your screen and click on «System Settings» from that menu, click on Software Sources (or you can click on the Ubuntu button and search for «Sources»:

enter image description here

and then on the Additional drivers tab:

enter image description here

Source | How do I install additional drivers?

Источник

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