29
July
2026
10:46

Passing a parameter to a Linux module/driver

29 July 2026 10:46

Specifying a parameter to launch a module or driver on Linux.

Kernel modules introduce additional functionality. For example, hardware support (drivers).
Some modules have launch parameters.

1) How can I find out which modules (drivers) are loaded into the Linux operating system?

sudo lsmod | less

Another way:

cd /lib/modules/$(uname -r)/kernel/drivers/ 
ls | less

2) How to display help information about a specific module?

sudo modinfo MODULE_NAME

where MODULE_NAME replace with the name of the module.

For example:

sudo modinfo rtw_usb

3) How to display abbreviated information only about the parameters of the module?

sudo modinfo -p MODULE_NAME

For example:

sudo modinfo -p rtw_usb

Conclusion:
switch_usb_mode : Set to N to disable switching to USB 3 mode to avoid
potential interference in the 2.4 GHz namd (default: Y) (boot)

4) How can I find out the current module parameter value in the system?

Some modules (not all) declare themselves in the directory structure /sys/module/MODULE_NAME/parameters

ls /sys/module/MODULE_NAME/parameters
cat /sys/module/MODULE_NAME/parameters/PARAMETER

where
MODULE_NAME - replace with the name of the module,
PARAMETER - replace with the parameter name.

Example:

cat /sys/module/rtw_usb/parameters/switch_usb_mode

Conclusion:
Y or N

5) How to pass a new parameter value to a module?

Parameter format:

MODULE_NAME.PARAMETER=VALUE

where VALUE is the value. For example, N.

Module parameters can be specified:

  • when building the kernel
  • when loading the PC in the kernel launch parameters - in the configuration file /etc/default/grub
  • real time in /proc/sys/

I will only consider the option when loading the PC

`GRUB_CMDLINE_LINUX_DEFAULT="quiet splash rtw_usb.switch_usb_mode=N"

where rtw_usb.switch_usb_mode=N - assigning the rtw_usb module to its switch_usb_mode parameter the value N.

Another example:

`GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nvidia-drm.modeset=1 nvidia-drm.fbdev=1"

Then you need to run the command

sudo update-grub

sudo reboot

Second way to specify a kernel module parameter

cd /etc/modprobe.d
ls
sudo nano /etc/modprobe.d/NAME.conf

in the NAME.conf file write:

options MODULE_NAME PARAMETER1=VALUE1 PARAMETER2=VALUE2

No dot!

Examples:

  • if the driver Nvidia, in file /etc/modprobe.d/nvidia.conf write
    options nvidia-drm modeset=1 fbdev=1

  • if the driver Nouveau, in file /etc/modprobe.d/nouveau.conf write
    options nouveau modeset=1

The line "GRUB_CMDLINE_LINUX_DEFAULT" in the /etc/default/grub file takes precedence over the /etc/modprobe.d/NAME.conf file.

6) Displaying parameters on the screen

  • Display kernel startup parameters when loading Linux OS

    cat /proc/cmdline

Result:
BOOT_IMAGE=/boot/vmlinuz-6.2.0-060200-generic root=UUID=xxxxx ro quiet splash init_on_alloc=1 slab_nomerge

  • Output parameters of one of the kernel modules

There is a utility called systool from the sysfsutils package, which can display the effective parameters of modules.

sudo apt install sysfsutils
systool -vm MODULE_NAME

where MODULE_NAME is the name of the module.

For example:

systool -vm rtw_usb
  • Output parameters of all kernel modules
cat /proc/modules | cut -f 1 -d " " | while read module; do\
echo "Module: $module"; \
if [ -d "/sys/module/$module/parameters" ]; then\
ls /sys/module/$module/parameters/ | while read parameter; do\
echo -n "Parameter: $parameter --> "; \
cat /sys/module/$module/parameters/$parameter; \
done; \
fi; \
echo; \
done

Sources:
How to Add, Remove, and Manage Linux Kernel Modules (Drivers)
How To Pass Module Specific Parameters To The LinuxKernel
*How do I list loaded Linux module parameter values?



Related publications