1. 添加脚本install_nfs.sh
根据需要修改脚本的nfs_share_dir目录
nfs_share_dir=/home/vk/nfs_share
sudo apt install nfs-kernel-server
sudo cp /etc/exports.bak /etc/exports
sudo cp /etc/exports /etc/exports.bak
sudo cat << EOF >> /etc/exports
${nfs_share_dir} *(rw,sync,no_root_squash)
EOF
sudo cp /etc/default/nfs-kernel-server.bak /etc/default/nfs-kernel-server
sudo cp /etc/default/nfs-kernel-server /etc/default/nfs-kernel-server.bak
# 在/etc/default/nfs-kernel-server末尾添加一行
sudo cat << EOF >> /etc/default/nfs-kernel-server
RPCNFSDOPTS="--nfs-version 2,3,4 --debug --syslog"
EOF
sudo service nfs-kernel-server restart
2. 测试nfs是否工作
sudo mount 192.168.0.105:/home/vk/nfs_share /mnt