Skip to content

网络共享盘与挂载

nfs服务端

bash
yum -y install nfs-utils
mkdir -pv /data/volumes
# 配置 /etc/exports 共享目录 允许网段(权限)
/data/volumes 192.168.56.0/24(rw,no_root_squash)

# 启动nfs服务
systemctl start nfs-server
systemctl enable nfs-server

# 更新 NFS 服务器的共享目录
exportfs -arv

挂载命令

bash
# cifs挂载 注意指定用户权限
# 以credentail file形式
echo "username=xxx" > ~/.credentials
echo "password=xxx" >> ~/.credentials
mount -t cifs -o credentials=~/.credentials //WIN_SHARE_IP/<share_name>,uid=test,gid=test /mnt/win_share

# 以账号密码形式
mount.cifs -o username=admin,password="P@ssw0rd",uid=test,gid=test //172.20.10.20/test /mnt/test

# nfs挂载
mount -t nfs -o nolock 172.18.1.240:/home/admin/work /mnt

自动挂载

写入/etc/fstab

bash
//WIN_SHARE_IP/share_name  /mnt/win_share  cifs  credentials=/etc/win-credentials,uid=1000,gid=1001,nofail 0       0

验证配置是否正确

bash
mount -a