linux – 使内核模块可用,已在Fedora上停用

前端之家收集整理的这篇文章主要介绍了linux – 使内核模块可用,已在Fedora上停用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
编辑:我把Cristians的答案变成了一个自动完成所有操作的脚本: https://github.com/frans-fuerst/magic/blob/master/fedora-activate-can.sh

我需要一些内核模块,这些模块可以在Linux源代码中使用,但在Fedora 20上停用,我想知道什么是最容易和最前进的方法来使它们可用. (即然后net / CAN支持导致一些can_ *模块)

>是否有fedora-repos / rpms可以使停用的模块可用?
>或者我必须手动编译这些模块吗?
>在这种情况下 – 是否有一些机制可以在内核更新的情况下自动执行此操作,或者我是否必须反复编译它们?

我已经遵循了this HowTo(并且还有更多类似的东西)但是“仅构建模块”部分似乎仅适用于尚未禁用的模块,因为在这种情况下甚至缺少模块源.

以下是我按照上述HowTo尝试的内容

首先,我尝试按照Out Of Tree Modules部分进行操作,但是在内核开发的该死的源代码树中,甚至缺少CAN支持的来源.
所以我尝试从src.rpm构建模块:

$yumdownloader --source kernel
$sudo yum-builddep kernel-3.14.8-200.fc20.src.rpm
$rpm -Uvh kernel-3.14.8-200.fc20.src.rpm
$cd ~/rpmbuild/SPECS
$rpmbuild -bp --target=$(uname -m) kernel.special
$cd ~/rpmbuild/BUILD/<kerneldir>/<linuxdir>
$<configure the kernel using menuconfig>
$make prepare

然后我建立并得到一些警告:

$make -C /lib/modules/`uname -r`/build M=`pwd`/net/can modules
make: Entering directory `<rpmbuild-BUILD-kernel-linux-dir>'

  WARNING: Symbol version dump <rpmbuild-BUILD-kernel-linux-dir>/Module.symvers
           is missing; modules will have no dependencies and modversions.

  CC [M]  <rpmbuild-BUILD-kernel-linux-dir>/net/can/bcm.o
  CC [M]  <rpmbuild-BUILD-kernel-linux-dir>/net/can/gw.o
  CC [M]  <rpmbuild-BUILD-kernel-linux-dir>/net/can/raw.o
  CC [M]  <rpmbuild-BUILD-kernel-linux-dir>/net/can/af_can.o
  CC [M]  <rpmbuild-BUILD-kernel-linux-dir>/net/can/proc.o
  LD [M]  <rpmbuild-BUILD-kernel-linux-dir>/net/can/can.o
  LD [M]  <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-raw.o
  LD [M]  <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-bcm.o
  LD [M]  <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-gw.o
  Building modules,stage 2.
  MODPOST 4 modules
  CC      <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-bcm.mod.o
  LD [M]  <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-bcm.ko
  CC      <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-gw.mod.o
  LD [M]  <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-gw.ko
  CC      <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-raw.mod.o
  LD [M]  <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-raw.ko
  CC      <rpmbuild-BUILD-kernel-linux-dir>/net/can/can.mod.o
  LD [M]  <rpmbuild-BUILD-kernel-linux-dir>/net/can/can.ko
make: Leaving directory `<rpmbuild-BUILD-kernel-linux-dir>'

$sudo make -C /lib/modules/`uname -r`/build M=`pwd`/net/can modules_install
make: Entering directory `<rpmbuild-BUILD-kernel-linux-dir>'
  INSTALL <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-bcm.ko
Can't read private key
  INSTALL <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-gw.ko
Can't read private key
  INSTALL <rpmbuild-BUILD-kernel-linux-dir>/net/can/can-raw.ko
Can't read private key
  INSTALL <rpmbuild-BUILD-kernel-linux-dir>/net/can/can.ko
Can't read private key
  DEPMOD  3.14.8
make: Leaving directory `<rpmbuild-BUILD-kernel-linux-dir>'

我刚刚运行make模块时没有收到第一个警告,但这花了我大约一个小时.

但是,安装后,.ko文件位于错误的目录中
(/usr/lib/modules/3.14.8而不是/usr/lib/modules/3.14.8-200.fc20.x86_64)并且在depmod -a和modprobe之后我可以得到

modprobe: ERROR: could not insert 'can': Exec format error

我究竟做错了什么?

解决方法

我想我得到了它,虽然它可能远非完美.

>通过运行准备源代码

rpmbuild -bp --target=$(uname -m) kernel.spec

>转到构建目录,例如:

cd ~/rpmbuild/BUILD/kernel-3.14.fc20/linux-3.14.8-200.fc20.x86_64

>编辑Makefile并将EXTRAVERSION设置为:

EXTRAVERSION = -200.fc20.x86_64

>启用模块.我建议从configs目录下的相应文件开始(我使用了kernel-3.14.8-x86_64.config).
>为模块准备内核:

make modules_prepare

>构建模块:

make M=drivers/net/can

>利润!插入模块:

insmod can-dev.ko

猜你在找的Linux相关文章