简体   繁体   中英

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? 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.

Linux kernel version - 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". So in your case you want something like "bonding.max_bonds=50" in the kernel command line.
  • 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. 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"). 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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