5-9
Friday
标签
梦涛笔记

Centos7 挂载NFS目录

CentOS 发布时间:2025-03-13 17:05:18
yum install nfs-utils

安装NFS工具集

showmount -e 192.168.248.208

检查 NFS 服务器端是否有目录共享:showmount -e nfs服务器的IP

cd /home && mkdir /nfs
mount -t nfs 192.168.248.208:/volume1/nfs /home/nfs

df -h 查看是否挂载成功。

设置开机自动挂载

vi /etc/fstab

添加:    192.168.248.208:/volume1/nfs /home/nfs nfs  defaults 0 0

关闭挂载:umount /usr/shareNFS nfs

windows挂载: mount  192.111.134.1:/usr/nfsShare X:

评论:
Jason
2025-03-30 21:30:12

服务端的启动和配置:

#创建共享目录
mkdir /home/nfs
chown nobody:nobody /home/nfs
chmod 777 /home/nfs

#配置NFS导出和权限
vi /etc/exports
#在文件中添加以下内容(根据需求调整客户端 IP 和权限)
/home/nfs 192.168.1.0/24(rw,sync,no_root_squash,no_subtree_check)

rw:读写权限
sync:同步写入
no_root_squash:允许 root 用户访问
no_subtree_check:禁用子树检查

#使配置生效
exportfs -a

#配置防火墙
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=mountd
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --reload

#启动服务
systemctl start nfs-server

#验证NFS共享
showmount -e localhost