编译内核模块 - 需要哪些包

时间:2017-11-01 09:06:10

标签: c makefile linux-kernel kernel-module

到现在为止,当我编译内核模块时,我安装了:kernel-devel,kernel-headers 后来,我不得不包含内核源代码 所以我现在安装的软件包是为了编译我的内核模块:kernel-devel,kernel-headers和kernel.src.rpm(内核源代码)。
我正在创建一个“构建机器”,它将检查可用的最新内核,下载必要的软件包并为该内核编译内核模块。
我不想安装软件包,只是为了下载它,并将文件复制到它们的位置(下载kernel.src.rpm,rpm2cpio,cpio,并复制到/ lib / modules / kernel-X-Y /) 我注意到如果安装了内核src,则不需要内核头文件。

需要kernel-devel ??,我不确定是什么,当尝试在没有kernel-devel的情况下安装时,我得到以下异常:

make[2]: Entering directory `/usr/src/kernels/3.10.0-693.el7.x86_64'

  ERROR: Kernel configuration is invalid.
         include/generated/autoconf.h or include/config/auto.conf are missing.
         Run 'make oldconfig && make prepare' on kernel src to fix it.
  WARNING: Symbol version dump ./Module.symvers
           is missing; modules will have no dependencies and modversions.

我错过了什么?如果我安装kernel-devel,那么我不会得到这个异常,我不想安装kernel-devel。

1 个答案:

答案 0 :(得分:3)

在运行make编译内核之前,您需要运行make oldconfig或将.config文件复制到构建树中。然后make oldconfig将使用.config并将其更新为更新的内核。

您还有其他选择:

内核源目录中的简单make help | grep -i config显示:

Configuration targets:
  config      - Update current config utilising a line-oriented program
  nconfig         - Update current config utilising a ncurses menu based
  menuconfig      - Update current config utilising a menu based program
  xconfig     - Update current config utilising a Qt based front-end
  gconfig     - Update current config utilising a GTK+ based front-end
  oldconfig   - Update current config utilising a provided .config as base
  localmodconfig  - Update current config disabling modules not loaded
  localyesconfig  - Update current config converting local mods to core
  silentoldconfig - Same as oldconfig, but quietly, additionally update deps
  defconfig   - New config with default from ARCH supplied defconfig
  savedefconfig   - Save current config as ./defconfig (minimal config)
  allnoconfig     - New config where all options are answered with no
  allyesconfig    - New config where all options are accepted with yes
  allmodconfig    - New config selecting modules when possible
  alldefconfig    - New config with all symbols set to default
  randconfig      - New config with random answer to all options
  listnewconfig   - List new options
  olddefconfig    - Same as silentoldconfig but sets new symbols to their
  kvmconfig   - Enable additional options for kvm guest kernel support
  xenconfig       - Enable additional options for xen dom0 and guest kernel support
  tinyconfig      - Configure the tiniest possible kernel
  kselftest-merge - Merge all the config dependencies of kselftest to existing
                    .config.
  configuration. This is e.g. useful to build with nit-picking config.
  i386_defconfig           - Build for i386
  x86_64_defconfig         - Build for x86_64
  make O=dir [targets] Locate all output files in "dir", including .config