Loading and Unloading Modules

Modules are loaded and unloaded by using the modprobe command. For more information, see the modprobe(8) and modules.dep(5) manual pages.
  • Load a kernel module using the modprobe command.

    The modprobe command loads kernel modules, for example:

    sudo modprobe nfs
    sudo lsmod | grep nfs
    nfs                   266415  0 
    lockd                  66530  1 nfs
    fscache                41704  1 nfs
    nfs_acl                 2477  1 nfs
    auth_rpcgss            38976  1 nfs
    sunrpc                204268  5 nfs,lockd,nfs_acl,auth_rpcgss

    Include the -v (verbose) option to show whether any other modules are loaded to resolve dependencies.

    sudo modprobe -v nfs
    insmod /lib/modules/4.18.0-80.el8.x86_64/kernel/net/sunrpc/auth_gss/auth_rpcgss.ko 
    insmod /lib/modules/4.18.0-80.el8.x86_64/kernel/fs/nfs_common/nfs_acl.ko 
    insmod /lib/modules/4.18.0-80.el8.x86_64/kernel/fs/fscache/fscache.ko 
    ...

    Note:

    The modprobe command doesn't reload modules that are already loaded. You must first unload a module before you can load it again.

  • Unload a module by using the modprobe -r command.

    Use the -r option to unload kernel modules:

    sudo modprobe -rv nfs
    rmmod /lib/modules/4.18.0-80.el8.x86_64/kernel/fs/nfs/nfs.ko
    rmmod /lib/modules/4.18.0-80.el8.x86_64/kernel/fs/lockd/lockd.ko
    rmmod /lib/modules/4.18.0-80.el8.x86_64/kernel/fs/fscache/fscache.ko
    ...

    Modules are unloaded in reverse order in which they were first loaded. Modules aren't unloaded if a process or another loaded module requires them.