尝试使用Shell脚本查找我的机器所需的所有内核模块 [英] Trying to find all the kernel modules needed for my machine using shell script

查看:109
本文介绍了尝试使用Shell脚本查找我的机器所需的所有内核模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在开发内核模块,构建时间已经开始深入人心了.作为副作用,我在构建过程中占用了太多的咖啡"时间.

I'm developing kernel modules right now, and the build times are starting to get under my skin. As a side effect I'm taking way too many "coffee" breaks during builds.

因此,我一直在寻找一种仅构建平台所需材料的方法. 简而言之,Linux内核"的第7章和第8章详细介绍了如何手动执行该操作.很好读: http://www.kroah.com/lkn/

So I was looking for a way to build only the stuffs I need for my platform. Chapter 7 and 8 of "linux kernel in a nutshell" gave a good detail of how to do that by hand. Its a good read : http://www.kroah.com/lkn/

但是,尽管我了解这些内容,但仍然需要进行很多调整才能使其正常工作.

But Although I understand the stuffs, this is still a lot of tweaks to make that work.

2.6.32和更高版本的内核添加了新的目标make localmodconfig.它会扫描lsmod并适当地更改.config.所以我以为我找到了自己的自动化".但是这个perl脚本也有一些问题.

2.6.32 and later kernels added a new target make localmodconfig. which scans through lsmod and change the .config appropriately. So I thought I found my "automation". But this perl script has some problem too.

此线程描述了问题: https://bbs.archlinux.org/viewtopic. php?pid = 845113

还有一个提议的解决方案,显然对其他人有用,它是直接运行脚本而不是使用make的目标.

There was also a proposed solution which apparently worked for others , is to run the script directly instead of using make's target.

尽管对我来说,使localmodconfig根本不起作用.其原因如下:

Although for me, make localmodconfig does not work at all. its because of the following :

make clean
make mrproper
cp /boo/config-'uname -r' .config
make localmodconfig

并停止

vboxguest config not found!!
nf_defrag_ipv6 config not found!!
vboxsf config not found!!
vboxvideo config not found!!

问题是我的内核开发环境在virtualbox内部.当我选择安装"virtualbox来宾添加"时,就安装了这些vbox模块.

The thing is my kernel development environment is inside virtualbox. These vbox modules were installed when I chose to install "virtualbox guest addtion".

netfilter模块可能是一个特定于发行版的模块(很多netfilter模块都不是主线内核的一部分,所以这对我来说并不奇怪),

And the netfilter module might be a Distribution specific module(Lot of netfilter modules are not part of the mainline kernel, so its not a shock to me), which is not included in mainline kernel.

现在,解决方法显然是卸载这些模块,然后重试.但是我在考虑是否有streamline_config.pl补丁,如果需要,它将使用户能够排除某些模块.问题是我对perl的了解为 zero ,我喜欢这种方式.

Now the workaround this obviously unloading these module and trying again. But I'm thinking if there is patch for the streamline_config.pl which will enable the user to exclude certain modules if s/he wants. Problem is I have zero knowledge about perl and I like it that way.

所以我在 nutshell

  1. 修补streamline_config.pl,因此我可以提供模块名称列表作为参数,以免处理配置文件.

  1. Patching streamline_config.pl so I can give a list of module name as argument which it will exclude from processing the config file.

该脚本位于删除了有关perl脚本未运行的内容.正如古根贤一指出的那样(我能有多愚蠢?).但是仍然使make localmodconfig无法工作,因为在源代码树下没有一些模块代码.修补streamline_config.pl仍然有效的要求.

Removed the stuff about perl script not running. As mugen kenichi pointed out (How dumb I can be?). But still make localmodconfig does not work because of not having some modules code under source tree. patching streamline_config.pl still valid requirement.

推荐答案

尝试构建最小内核映像并寻求减少构建时间的其他任何人,都应执行以下操作:

Anyone else trying to build a minimum kernel image also looking for reducing build time, should do the following:

1)在源代码树中复制分发内核配置.可以使用以下任一命令来完成此操作:

1) copy distribution kernel config in your source tree. It can be done with either command given below:

$zcat /proc/config.gz > .config

$cp /boot/config-'uname -r' .config

2)使用localmodconfig目标.

2) Use localmodconfig target.

$make localmodconfig

它将使用lsmod查找当前正在加载的模块.然后它将搜索发行版的.config启用它们并禁用其他.

It will use lsmod to find which modules are loaded at this moment. Then it will search through distribution's .config to enable them and disable others.

重要的是要知道它并不总是完美无瑕的.因此,您应该使用make menuconfig进一步调整配置.您会看到一些模块仍标记为已构建,实际上这对于您的系统来说是不必要的.

Its important to know that it does not always work flawlessly. So you should tweak your config further using make menuconfig. You will see some modules are still marked to be built which is in reality unnecessary for your system.

有时树模块不足可能会导致make localmodconfig失败.如果是这种情况,您可以通过两种方式解决该问题:

Sometimes out of tree modules may cause make localmodconfig to fail. If that's the case you can work around that issue in two ways :

a)卸载树外模块,然后再次尝试. b)直接运行perl脚本:

a) unload the out of tree modules and try make localmodconfig again. b) Run the perl script directly:

$chmod +x script/kconfig/streamline_config.pl
$perl script/kconfig/streamline_config.pl > .config

3)安装ccache [1].它将大大缩短您的构建时间.它缓存对象.因此,它将减少后续构建.

3) Install ccache[1]. It will improve your build time dramatically. It caches objects. So it will reduce subsequent builds.

ccache可能包含在发行版的存储库中,因此您可以通过apt-getyum安装它.在CentOS中,它可以在EPEL仓库中使用.[2]

Its possible that ccache is included in the distribution's repository so that you can install it through apt-get or yum. In CentOS its available in EPEL repo.[2]

4)为构建作业提供尽可能多的内核

4) Give as many cores as possible for the build job

$make -j8 CC="ccache gcc"

我的结果是:

real 3m10.871s
user 4m36.949s
sys 1m52.656s

[1] http://ccache.samba.org/ [2] http://fedoraproject.org/wiki/EPEL

[1] http://ccache.samba.org/ [2] http://fedoraproject.org/wiki/EPEL

这篇关于尝试使用Shell脚本查找我的机器所需的所有内核模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆