天天看点

linux kernel module parameters

http://baruch.siach.name/blog/posts/linux_kernel_module_parameters/

Setting Linux kernel module parameters

Many Linux kernel modules have parameters that can be set at load time, boot time, and sometimes run-time. In the following I'll demonstrate each method.

Setting module parameter at load time

The easiest way to load kernel modules at run time is using the

modprobe

command. To set a module parameter put the parameter name and value in the

modprobe

command line:

modprobe foo parameter=value            

The command

modinfo

lists the parameters that a given kernel module accepts, with the expected type of each parameter. For example, on my Linux 3.2 based system the command

modinfo ambassador

shows the following parameters info:

parm:           debug:debug bitmap, see .h file (ushort) parm:           cmds:number of command queue entries (uint) parm:           txs:number of TX queue entries (uint) parm:           rxs:number of RX queue entries [4] (array of uint) parm:           rxs_bs:size of RX buffers [4] (array of uint) parm:           rx_lats:number of extra buffers to cope with RX latencies (uint) parm:           pci_lat:PCI latency in bus cycles (byte)            

Simple values of type byte or uint are represented by a number:

modprobe ambassador debug=1            

Array values are set using a comma separated list of values:

modprobe ambassador rxs=1000,2000,3000,4000            
modprobe parport_pc init_mode=epp            

Setting module parameters at boot time

ambassador.debug=1  ambassador.rxs=1000,2000,3000,4000  parport_pc.init_mode=epp            

Setting module parameters at run-time

echo -n 1 > /sys/module/ambassador/parameters/debug  
           

继续阅读