加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

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

发布时间:2020-12-13 16:53:24 所属栏目:Linux 来源:网络整理
导读:编辑:我把Cristians的答案变成了一个自动完成所有操作的脚本: https://github.com/frans-fuerst/magic/blob/master/fedora-activate-can.sh 我需要一些内核模块,这些模块可以在Linux源代码中使用,但在Fedora 20上停用,我想知道什么是最容易和最前进的方法
编辑:我把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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读