简体   繁体   English

在编译时将参数传递给内置内核模块

[英]Passing parameter to builtin kernel module at compile time

Is there a way to pass parameter to builtin kernel module while compiling the linux kernel? 有没有一种方法可以在编译linux内核时将参数传递给内置内核模块? If yes, can you please explain how? 如果是,请解释一下吗? I want to pass value for max_bonds to bonding driver which is builtin module in my kernel. 我想将max_bonds的值传递给内核中内置模块的bonding驱动程序。

Linux kernel version - 2.6 Linux内核版本-2.6

You can use two kernel features to accomplish this: 您可以使用两个内核功能来完成此任务:

  • You can pass module parameter values to built-in modules via the kernel command line as "modulename.param=value". 您可以通过内核命令行将模块参数值作为“ modulename.param = value”传递给内置模块。 So in your case you want something like "bonding.max_bonds=50" in the kernel command line. 因此,在您的情况下,您希望在内核命令行中输入“ bonding.max_bonds = 50”之类的内容。
  • Since 2.6.28 or so (hope your kernel isn't older than that), the kernel supports setting a default command line at compile time via CONFIG_CMDLINE_BOOL ("Built-in kernel command line") and CONFIG_CMDLINE. 由于2.6.28左右(希望您的内核不早于该内核),内核支持在编译时通过CONFIG_CMDLINE_BOOL(“内置内核命令行”)和CONFIG_CMDLINE设置默认命令行。 You set CONFIG_CMDLINE_BOOL=y and then set CONFIG_CMDLINE to whatever you want in your kernel command line (for example, "bonding.max_bonds=50"). 您设置CONFIG_CMDLINE_BOOL = y,然后将CONFIG_CMDLINE设置为内核命令行中想要的任何值(例如,“ bonding.max_bonds = 50”)。 Any further command line options that your boot loader passes to the kernel are appended to the default command line you set in the kernel config. 您的引导加载程序传递给内核的任何其他命令行选项都将附加到您在内核配置中设置的默认命令行。

By using those two features, I think you get pretty much exactly what you want, without modifying any kernel source, just tweaking your config file. 通过使用这两个功能,我认为您几乎完全可以得到所需的内容,而无需修改任何内核源代码,只需调整配置文件即可。

I think it is possible by changing modules source. 我认为可以通过更改模块源来实现。 Each modules parameter has its default value coded in sources - just modify it. 每个模块参数在源代码中都有其默认值-只需对其进行修改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM