How do I load kernel modules during boot time in RHEL 7 or 8?
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:
-
Recommended: Use
systemd-modules-load.serviceto load the modules during boot.-
Add a file in
/etc/modules-load.d/<name>.confcontaining 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 -
Run the below command to start the systemd service,
# systemctl restart systemd-modules-load
-
-
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?
-
Use
/etc/rc.localto load the modules. You can add the below lines to load the modules during reboot. Make sure/etc/rc.localis executable.modprobe <module-1 name> modprobe <module-2 name> modprobe <module-3 name>
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.