×

在CentOS7启动时自动加载内核模块

hqy hqy 发表于2019-04-09 10:15:43 浏览2644 评论0

抢沙发发表评论

在CentOS7启动时自动加载内核模块

添加相应模块  脚本

[root@localhost ~]# cat /etc/sysconfig/modules/kvm.modules 
#!/bin/bash

/sbin/modinfo -F filename kvm > /dev/null 2>&1
if [ $? -eq 0 ]; then
    /sbin/modprobe kvm
fi

 

[root@localhost ~]# chmod +x kvm.modules

 

重启测试

 

  1. 查看所有模块:

    lsmod

    centos7内核模块命令

  2. 查看指定模块的详细信息:

    modinfo  模块名

    centos7内核模块命令

  3. 动态加载模块:

    modprobe  模块名
  4. 动态卸载模块:

    modprobe  -r  模块名




以ceph模块为例:

  1. #cd /etc/sysconfig/modules/

  2. #vim ceph.modules

  3. 在文件中添加如下内容 
    #!/bin/sh 
    /sbin/modinfo -F filename ceph > /dev/null 2>&1 
    if [ $? -eq 0 ]; then 
        /sbin/modprobe ceph 
    fi

  4. #chmod 755 ceph.modules   //这一步至关重要

  5. #reboot

现在重启,在命令行运行

#lsmod | grep ceph

就可以看到ceph模块被加载到系统中 :)

这只是加载模块的一种方式


 您阅读本篇文章共花了: 

打赏

本文链接:https://kinber.cn/post/530.html 转载需授权!

分享到:


推荐本站淘宝优惠价购买喜欢的宝贝:

image.png

群贤毕至

访客