1.安装nfs服务器端与客户端
$sudo apt-get install nfs-kernel-server nfs-common portmap
安装客户端的作用是可以在本机进行nfs测试
2.配置portmap
方法1:通过编辑/etc/default/portmap
$sudo vi /etc/default/portmap
1 # Portmap configuration file
2 #
3 # Note: if you manually edit this configuration file,
4 # portmap configuration scripts will avoid modifying it
5 # (for example, by running 'dpkg-reconfigure portmap').
6
7 # If you want portmap to listen only to the loopback
8 # interface, uncomment the following line (it will be
9 # uncommented automatically if you configure this
10 # through debconf).
11 #OPTIONS=""
注释掉最后一行OPTIONS.
方法2:
$sudo dpkg-reconfigure portmap
运行后选择.
另外,要用sysv-rc-conf(不是chkconfig)工具查看一下当前nfs和portmap的 状态,若是off,则用sudo sysv-rc-conf portmap on 或 sudo sysv-rc-confnfs- kernel-server on 打开。
3.配置挂载目录
$sudo vi /etc/exports
1 # /etc/exports: the access control list for filesystems which may be exporte d
2 # to NFS clients. See exports(5).
3 #
4 # Example for NFSv2 and NFSv3:
5 # /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_ subtree_check)
6 #
7 # Example for NFSv4:
8 # /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
9 # /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
10 #
11 /home/nfs/qemu-target-armv5l 192.168.200.*(rw,no_root_squash,subtree_check,async)
做后一行是所需配置
4.创建共享文件夹
sudo mkdir /home/nfs/qemu-target-armv5l
5.更新exports文件
更改了/etc/exports之后,通过下面命令更新生效
$sudo exportfs -r
6.重启nfs服务
$sudo /etc/init.d/nfs-kernel-server restart
7.挂载
$sudo mount -t nfs localhost:/home/nfs/qemu-target-armv5l /mnt
8.查看
$showmount -e localhost
卸载NFS服务
$sudo umount /mnt
阅读(1768) | 评论(1) | 转发(0) |