How do I load kernel modules during boot time in RHEL 7 or 8?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 8

Issue

  • How do I load certain modules one after another during boot time in RHEL 7 or 8?
  • How do I set the order to load certain modules in RHEL 7 or 8? We need to make sure that a particular module loads first before the other.

Resolution

If you want to load modules that have dependencies then you can use the modprobe command. It will automatically resolve the dependencies and load the modules.

Here are three ways to accomplish loading modules at boot automatically:

  1. Recommended: Use systemd-modules-load.service to load the modules during boot.

    1. Add a file in /etc/modules-load.d/<name>.conf containing module names. It will read the lines in order and load the modules sequentially.

       # Load the below modules at boot
       module-1
       module-2
       module-3
      
    2. Run the below command to start the systemd service,

       # systemctl restart systemd-modules-load
      
  2. Insert the modules in the initramfs of the loaded kernel. You can refer to the following solution for guidance: How can I ensure certain modules are included in the initrd or initramfs in RHEL?

  3. Use /etc/rc.local to load the modules. You can add the below lines to load the modules during reboot. Make sure /etc/rc.local is executable.

     modprobe <module-1 name>
     modprobe <module-2 name>
     modprobe <module-3 name>
    
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.