Load kernel modules persistently

modprobe command can be used for loading kernel modules
# modprobe <kernel module name>
modprobe command doesn't ensure that the kernel module gets loaded into the system kernel every time the system boots up. Hence there comes a need to load kernel modules in persistent way.

Ubuntu Linux:

In Ubuntu Linux,  /etc/modules file is made available to provide support to load kernel modules at boot time. you can edit the file to add module name that needs to be loaded into the system persistently

Use any editor to add the module name into /etc/modules file

Example:
# echo "nbd" >> /etc/modules
Redhat / Centos Linux:

You can follow one among the below methods

Method 1:

Create a shell script file and store that in .modules extension, change the file permissions to executable and store that under /etc/sysconfig/modules directory. You can create as many .modules files as you want or keep all modules in single .modules file

Example:
# vi /etc/sysconfig/modules/nbd.modules
File content:
#!/bin/sh

/sbin/insmod nbd

Save the file and change permissions to executable
# chmod +x /etc/sysconfig/modules/nbd.modules

Method 2:

Edit /etc/rc.local file and append the "/sbin/modprobe nbd" command


Now system will load the modules when ever it boots up.

Post a Comment

0 Comments