设置NFS开机自动挂载?

 时间:2026-02-12 15:43:51

1、步骤一:编辑shell脚本/usr/local/sbin/nfsboot.sh,内容如下

[root@knode1 ~]# cat /usr/local/sbin/nfsboot.sh

#!/bin/bash

## This is NFS disk automount shell script

echo "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;

exit

fi

echo "执行完毕" >> nfs.log

设置NFS开机自动挂载?

2、步骤二:给脚本赋予执行权限

chmod +x /usr/local/sbin/nfsboot.sh

设置NFS开机自动挂载?

3、步骤三:将脚本加入开机自启动中

如下,将/usr/local/sbin/nfsboot.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

然后服务器重启验证是否自动挂载

  • 魔兽争霸3omg大乱斗攻略?
  • linux设置主副屏
  • ORICO硬盘组如何设置raid5
  • Windows7如何禁用磁盘碎片自动整理程序?
  • 苹果手机怎么设置流量下载不限制
  • 热门搜索
    文化大革命是怎么回事 月经期间怎么减肥 婚后财产离婚怎么分 basketball怎么读 word怎么调整行距 延时环怎么用 记忆力下降怎么办 怎么查手机流量 公司介绍怎么写 怎么做代理商