如何在Linux内核中显示模块或设备驱动程序的列表
时间:2020-01-09 10:40:10 来源:igfitidea点击:
如何在Linux操作系统上显示已加载的Linux内核模块或设备驱动程序的列表?
您需要使用lsmod
程序来显示Linux内核中已加载模块的状态。
Linux内核对所有硬件设备驱动程序使用术语模块。
请注意hatslsmod是一个简单的程序,它很好地格式化了/proc/modules的内容,显示了当前正在加载的内核模块。
使用lsmod,您可以验证是否为特定硬件加载了设备驱动程序。
任何硬件设备仅在加载设备驱动程序后才能工作。
列出或显示已加载的模块
打开终端或登录ssh会话并执行以下命令
$ less /proc/modules
输出示例:
sha1_generic 1759 4 - Live 0xffffffffa059e000 arc4 1274 2 - Live 0xffffffffa0598000 ecb 1841 2 - Live 0xffffffffa0592000 ppp_mppe 5240 2 - Live 0xffffffffa058b000 ppp_async 6245 1 - Live 0xffffffffa0584000 crc_ccitt 1323 1 ppp_async, Live 0xffffffffa057e000 ppp_generic 19291 6 ppp_mppe,ppp_async, Live 0xffffffffa0572000 slhc 4003 1 ppp_generic, Live 0xffffffffa056c000 ext3 106854 1 - Live 0xffffffffa0546000 jbd 37349 1 ext3, Live 0xffffffffa0533000 sha256_generic 8692 2 - Live 0xffffffffa0525000 aes_x86_64 7340 2 - Live 0xffffffffa0517000 aes_generic 25714 1 aes_x86_64, Live 0xffffffffa050b000 .... ... .... ahci 32950 20 - Live 0xffffffffa007b000 libata 133824 3 ata_generic,pata_jmicron,ahci, Live 0xffffffffa0045000 scsi_mod 126901 3 usb_storage,sd_mod,libata, Live 0xffffffffa0012000 thermal 11674 0 - Live 0xffffffffa0009000 thermal_sys 11942 3 video,processor,thermal, Live 0xffffffffa0000000
要查看格式正确的输出,请执行:
$ lsmod
输出示例:
Module Size Used by sha1_generic 1759 4 arc4 1274 2 ecb 1841 2 ppp_mppe 5240 2 ppp_async 6245 1 crc_ccitt 1323 1 ppp_async ppp_generic 19291 6 ppp_mppe,ppp_async slhc 4003 1 ppp_generic ext3 106854 1 jbd 37349 1 ext3 sha256_generic 8692 2 aes_x86_64 7340 2 aes_generic 25714 1 aes_x86_64 cbc 2539 1 nfsd 254974 13 exportfs 3186 1 nfsd nfs 241498 0 lockd 57651 2 nfsd,nfs fscache 29882 1 nfs nfs_acl 2031 2 nfsd,nfs auth_rpcgss 33524 2 nfsd,nfs sunrpc 161756 12 nfsd,nfs,lockd,nfs_acl,auth_rpcgss fuse 51020 1 dm_crypt 10680 1 it87 15879 0 hwmon_vid 1828 1 it87 coretemp 4325 0 loop 11799 0 snd_pcm 60487 0 usb_storage 40233 0 i915 257462 0 snd_timer 15598 1 snd_pcm drm_kms_helper 20369 1 i915 snd 46542 2 snd_pcm,snd_timer ata_generic 3239 0 drm 143120 2 i915,drm_kms_helper soundcore 4598 1 snd snd_page_alloc 6265 1 snd_pcm uhci_hcd 18537 0 i2c_algo_bit 4209 1 i915 psmouse 49969 0 ehci_hcd 32145 0 video 17445 1 i915 i2c_i801 7830 0 evdev 7352 2 pata_jmicron 2280 0 pcspkr 1699 0 serio_raw 3752 0 usbcore 123399 4 usb_storage,uhci_hcd,ehci_hcd i2c_core 15835 5 i915,drm_kms_helper,drm,i2c_algo_bit,i2c_i801 nls_base 6567 1 usbcore output 1692 1 video e1000e 124884 0 button 4650 1 i915 processor 29951 0 ext4 288755 2 mbcache 5050 2 ext3,ext4 jbd2 67175 1 ext4 crc16 1319 1 ext4 dm_mod 53994 6 dm_crypt raid456 44516 4 md_mod 73936 5 raid456 async_raid6_recov 5186 1 raid456 async_pq 3495 2 raid456,async_raid6_recov raid6_pq 77179 2 async_raid6_recov,async_pq async_xor 2494 3 raid456,async_raid6_recov,async_pq xor 4380 1 async_xor async_memcpy 1198 2 raid456,async_raid6_recov async_tx 1750 5 raid456,async_raid6_recov,async_pq,async_xor,async_memcpy sd_mod 29953 25 crc_t10dif 1276 1 sd_mod ahci 32950 20 libata 133824 3 ata_generic,pata_jmicron,ahci scsi_mod 126901 3 usb_storage,sd_mod,libata thermal 11674 0 thermal_sys 11942 3 video,processor,thermal
第一列是模块名称,第二列是模块的大小,即输出格式是模块名称,大小,使用计数,引用模块列表。
查找有关任何模块或驱动程序的更多信息
执行以下命令:
# modinfo driver-Name-Here # modinfo thermal_sys # modinfo e1000e
输出示例:
filename: /lib/modules/2.6.32-5-amd64/kernel/drivers/net/e1000e/e1000e.ko version: 1.2.20-k2 license: GPL description: Intel(R) PRO/1000 Network Driver author: Intel Corporation, <[email protected]> srcversion: AB58ACECA1618E521F58503 alias: pci:v00008086d00001503sv*sd*bc*sc*i* alias: pci:v00008086d00001502sv*sd*bc*sc*i* alias: pci:v00008086d000010F0sv*sd*bc*sc*i* alias: pci:v00008086d000010EFsv*sd*bc*sc*i* alias: pci:v00008086d000010EBsv*sd*bc*sc*i* alias: pci:v00008086d000010EAsv*sd*bc*sc*i* alias: pci:v00008086d00001525sv*sd*bc*sc*i* alias: pci:v00008086d000010DFsv*sd*bc*sc*i* alias: pci:v00008086d000010DEsv*sd*bc*sc*i* alias: pci:v00008086d000010CEsv*sd*bc*sc*i* alias: pci:v00008086d000010CDsv*sd*bc*sc*i* alias: pci:v00008086d000010CCsv*sd*bc*sc*i* alias: pci:v00008086d000010CBsv*sd*bc*sc*i* alias: pci:v00008086d000010F5sv*sd*bc*sc*i* alias: pci:v00008086d000010BFsv*sd*bc*sc*i* alias: pci:v00008086d000010E5sv*sd*bc*sc*i* alias: pci:v00008086d0000294Csv*sd*bc*sc*i* alias: pci:v00008086d000010BDsv*sd*bc*sc*i* alias: pci:v00008086d000010C3sv*sd*bc*sc*i* alias: pci:v00008086d000010C2sv*sd*bc*sc*i* alias: pci:v00008086d000010C0sv*sd*bc*sc*i* alias: pci:v00008086d00001501sv*sd*bc*sc*i* alias: pci:v00008086d00001049sv*sd*bc*sc*i* alias: pci:v00008086d0000104Dsv*sd*bc*sc*i* alias: pci:v00008086d0000104Bsv*sd*bc*sc*i* alias: pci:v00008086d0000104Asv*sd*bc*sc*i* alias: pci:v00008086d000010C4sv*sd*bc*sc*i* alias: pci:v00008086d000010C5sv*sd*bc*sc*i* alias: pci:v00008086d0000104Csv*sd*bc*sc*i* alias: pci:v00008086d000010BBsv*sd*bc*sc*i* alias: pci:v00008086d00001098sv*sd*bc*sc*i* alias: pci:v00008086d000010BAsv*sd*bc*sc*i* alias: pci:v00008086d00001096sv*sd*bc*sc*i* alias: pci:v00008086d0000150Csv*sd*bc*sc*i* alias: pci:v00008086d000010F6sv*sd*bc*sc*i* alias: pci:v00008086d000010D3sv*sd*bc*sc*i* alias: pci:v00008086d0000109Asv*sd*bc*sc*i* alias: pci:v00008086d0000108Csv*sd*bc*sc*i* alias: pci:v00008086d0000108Bsv*sd*bc*sc*i* alias: pci:v00008086d0000107Fsv*sd*bc*sc*i* alias: pci:v00008086d0000107Esv*sd*bc*sc*i* alias: pci:v00008086d0000107Dsv*sd*bc*sc*i* alias: pci:v00008086d000010B9sv*sd*bc*sc*i* alias: pci:v00008086d000010D5sv*sd*bc*sc*i* alias: pci:v00008086d000010DAsv*sd*bc*sc*i* alias: pci:v00008086d000010D9sv*sd*bc*sc*i* alias: pci:v00008086d00001060sv*sd*bc*sc*i* alias: pci:v00008086d000010A5sv*sd*bc*sc*i* alias: pci:v00008086d000010BCsv*sd*bc*sc*i* alias: pci:v00008086d000010A4sv*sd*bc*sc*i* alias: pci:v00008086d0000105Fsv*sd*bc*sc*i* alias: pci:v00008086d0000105Esv*sd*bc*sc*i* depends: vermagic: 2.6.32-5-amd64 SMP mod_unload modversions parm: copybreak:Maximum size of packet that is copied to a new buffer on receive (uint) parm: TxIntDelay:Transmit Interrupt Delay (array of int) parm: TxAbsIntDelay:Transmit Absolute Interrupt Delay (array of int) parm: RxIntDelay:Receive Interrupt Delay (array of int) parm: RxAbsIntDelay:Receive Absolute Interrupt Delay (array of int) parm: InterruptThrottleRate:Interrupt Throttling Rate (array of int) parm: IntMode:Interrupt Mode (array of int) parm: SmartPowerDownEnable:Enable PHY smart power down (array of int) parm: KumeranLockLoss:Enable Kumeran lock loss workaround (array of int) parm: WriteProtectNVM:Write-protect NVM [WARNING: disabling this can lead to corrupted NVM] (array of int) parm: CrcStripping:Enable CRC Stripping, disable if your BMC needs the CRC (array of int)
Linux中是否存在用于存储驱动程序文件的标准目录?
执行以下命令以查看驱动程序文件所在的目录位置:
echo "Kernel drivers dir: \"/lib/modules/$(uname -r)/kernel/drivers/\" \ for Linux kernel version \"$(uname -r)\" "
要查看驱动程序,请执行:
ls -l /lib/modules/$(uname -r)/kernel/drivers/
输出示例:
acpi block dca fmc hv infiniband lightnvm memstick net parport power regulator ssb uio virtio ata bluetooth dma fpga hwmon input macintosh message nfc pci powercap remoteproc staging usb vme atm char edac gpio hwtracing iommu mailbox mfd ntb pcmcia pps rtc target uwb w1 auxdisplay clk extcon gpu i2c ipack mcb misc nvdimm phy ptp scsi thermal vfio watchdog base cpufreq firewire hid idle isdn md mmc nvme pinctrl pwm spi thunderbolt vhost xen bcma crypto firmware hsi iio leds media mtd nvmem platform rapidio spmi tty video
如何确定是否安装了特定的模块/驱动程序?
语法为:
$ find /lib/modules/$(uname -r)/kernel/drivers/ -iname "driver-to-search-here"
要确定是否安装了名为foo.ko的驱动程序,请运行:
$ find /lib/modules/$(uname -r)/kernel/drivers/ -iname "foo.ko"
查找是否已安装e1000e驱动程序:
$ find /lib/modules/$(uname -r)/kernel/drivers/ -iname "*e1000e*.ko" $ find /lib/modules/$(uname -r)/kernel/drivers/ -iname "e1000e.ko"
在驱动程序名称上运行modinfo:
$ modinfo e1000e