Administrator
发布于 2021-12-29 / 285 阅读
0
0

Contos7-通过脚本配置开机自动挂载nfs

Contos7-通过脚本配置开机自动挂载nfs

1、安装nfs客户端

yum -y install nfs-utils

#测试nfs是否可用
showmount -e 192.168.37.23

2、配置自动挂载

vi /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 /opt/video_bak | wc -l`

if [ $val -eq 1 ]
then
  echo "NFS目录/opt/video_bak已经挂载,无需再挂" >> nfs.log;
else 
  mount -t nfs 192.168.37.23:/volume1/hzgwd /opt/video_bak
  echo  "NFS目录/opt/video_bak挂载成功" >> nfs.log;
exit
fi
echo "执行完毕" >> nfs.log
#######################################


#给脚本赋予执行权限
chmod +x /usr/local/sbin/nfsboot.sh

#将脚本加入开机自启动中
vi /etc/rc.d/rc.local

#输入i 在最后面插入
/usr/local/sbin/nfsboot.sh

#添加权限
chmod +x /etc/rc.d/rc.local  

评论