设置NFS开机自动挂载

2025-05-10 19:25:39

1、步骤一:编辑shell脚本/usr/local/sbin/nfsboot.sh,内容如下[root@knode1 韵簿儒回~]# cat /usr/local/sbin/nfsboot.sh#!/bin/bash## This is NFS disk automount shell scriptecho "NFS启动时间点:$(date +"%F %T")" >>nfs.log;val=`df -h|grep website | wc -l`if [ $val -eq 1 ] then echo "NFS目录/tmp/website已经挂载,无需再挂" >> nfs.log; else mount -o vers=3 10.200.18.100:/tmp/website/ /tmp/website/ echo "NFS目录/tmp/website挂载成功" >> nfs.log; exitfiecho "执行完毕" >> nfs.log

设置NFS开机自动挂载

2、步骤二:给脚本赋予执行权限chmod +x /usr/local/sbin/nfsboot.sh

设置NFS开机自动挂载

3、步骤三:将脚本加入开机自启动中如下,将/usr/local/sbin/nfs水瑞侮瑜boot.sh脚本加入自启动中[root@knode1 ~]# cat /etc/rc.d/rc.local#!/bin/bash# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES## It is highly advisable to create own systemd services or udev rules# to run scripts during boot instead of using this file.## In contrast to previous versions due to parallel execution during boot# this script will NOT be run after all other services.## Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure# that this script will be executed during boot.touch /var/lock/subsys/local/usr/local/sbin/nfsboot.sh

设置NFS开机自动挂载

4、步骤四:赋予脚本执行权限chmod +x /etc/rc.d/rc.local然后服务器重启验证是否自动挂载

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢