Amazon-Ec2

使用 dkms 建構核心模組,缺少標頭

  • May 3, 2019

如果有人可以幫助我,我將不勝感激。

1)我正在嘗試使用 dkms 為 Ubuntu 伺服器建構核心模組。詳細手冊在這裡

2)當它使用這種語法建構模組時:

sudo dkms build -m ixgbevf -v 2.15.3

它說,缺少一些核心標頭檔:

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area....(bad exit status: 2)
cd src/; make BUILD_KERNEL=....(bad exit status: 2)
ERROR (dkms apport): binary package for ixgbevf: 2.15.3 not found
Error! Bad return status for module build on kernel: 3.13.0-36-generic (x86_64)
Consult /var/lib/dkms/ixgbevf/2.15.3/build/make.log for more information.

3)日誌文件:/var/lib/dkms/ixgbevf/2.15.3/build/make.log:

DKMS make.log for ixgbevf-2.15.3 for kernel 3.13.0-36-generic (x86_64)
Tue Dec 23 09:27:47 UTC 2014
Makefile:64: *** Kernel header files not in any of the expected locations.
Makefile:65: *** Install the appropriate kernel development package, e.g.
Makefile:66: *** kernel-devel, for building kernel modules and try again.  Stop.

4)我在這裡有標題:

/usr/src/linux-headers-3.13.0-36
/usr/src/linux-headers-3.13.0-36-generic
/usr/include

並且 cpp -v 顯示:

#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include

如果您需要更多資訊,我會立即為您提供。謝謝。

— 添加資訊 —

  1. dpkg -l | grep linux-headers 顯示:
ii  linux-headers-3.13.0-36          3.13.0-36.63                         all          Header files related to Linux kernel version 3.13.0
ii  linux-headers-3.13.0-36-generic  3.13.0-36.63                         amd64        Linux kernel headers for version 3.13.0 on 64 bit x86 SMP
ii  linux-headers-generic            3.13.0.36.43                         amd64        Generic Linux kernel headers
ii  linux-headers-virtual            3.13.0.36.43                         amd64        Transitional package.
  1. dpkg -l | 的輸出資訊 grep linux 映像
ii  linux-image-3.13.0-36-generic    3.13.0-36.63                         amd64        Linux kernel image for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-virtual              3.13.0.36.43                         amd64        This package will always depend on the latest minimal generic kernel image.
  1. uname -a 的輸出
Linux ip-10-0-3-11 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
  1. ixgbevf 模組的源連結在這裡

所以,最後,我設法為核心版本 3.13.0-43 安裝了驅動程序 ixgbevf v. 2.15.3。

但是,有一些重要的點:

  1. 首先,我嘗試使用make手動建構它並得到相同的結果:
Makefile:64: *** Kernel header files not in any of the expected locations.
Makefile:65: *** Install the appropriate kernel development package, e.g.
Makefile:66: *** kernel-devel, for building kernel modules and try again.  Stop.
  1. 其次,我執行apt-get upgrade並將apt-get dist-upgrade核心從 3.13.0-36 更新到 3.13.0-43,然後重新啟動機器以更新核心。詳情在這裡。它還為 3.13.0-43 安裝了核心標頭檔。
  2. 第三,我必須更改 dkms.conf 配置文件,如下所示:
MAKE="make -C src/ KERNELDIR=/lib/modules/${kernelver}/build"
CLEAN="make -C src/ clean"
BUILT_MODULE_NAME=ixgbevf
BUILT_MODULE_LOCATION=src/
DEST_MODULE_LOCATION="/updates"
PACKAGE_NAME=ixgbevf-dkms
PACKAGE_VERSION=2.15.3
REMAKE_INITRD=no

之後,它能夠建構驅動程序。如果您有同樣的問題並需要幫助,請隨時與我聯繫。@Faheem Mitha,非常感謝您的幫助。

有一個針對 Ubuntu14.04 發布的更新檔https://gist.github.com/cdgraff/1c31727901e5c76d5ea8

我可以確認它正在工作:

root@ip-172-31-119-53:~# modinfo ixgbevf
filename:       /lib/modules/3.13.0-45-generic/updates/dkms/ixgbevf.ko
version:        2.16.1
license:        GPL
description:    Intel(R) 10 Gigabit Virtual Function Network Driver
author:         Intel Corporation, <linux.nics@intel.com>
srcversion:     3F8AACF779F38FD444B1CD3
alias:          pci:v00008086d00001515sv*sd*bc*sc*i*
alias:          pci:v00008086d000010EDsv*sd*bc*sc*i*
depends:        
vermagic:       3.13.0-45-generic SMP mod_unload modversions 
parm:           InterruptThrottleRate:Maximum interrupts per second, per    vector, (956-488281, 0=off, 1=dynamic), default 1 (array of int)

引用自:https://unix.stackexchange.com/questions/175732