配置Ubuntu 10.10的 NFS 服务


配置NFS服务(Ubuntu-10.10-desktop)

NFS(Network File System, 网络文件系统)可以通过网络将分享不同主机(不同的OS)的目录——可以通过NFS挂载远程主机的目录, 访问该目录就像访问本地目录一样!(操作之前最好先切换到root用户下)


进行NFS服务器端与客户端的安装:

sudo apt-get install nfs-kernel-server  nfs-common  portmap
提示是否需要继续:Y

Do you want to continue [Y/n]? Y
安装客户端的作用是可以在本机进行NFS服务的测试。

配置portmap

 sudo dpkg-reconfigure portmap
运行后选择“No”

配置挂载目录和权限

vim /etc/exports
我的配置如下:

 # /etc/exports: the access control list for filesystems which may be exported
 #  to NFS clients.  See exports(5).
 #
 # Example for NFSv2 and NFSv3:
 # /srv/homes       hostname1(rw,sync) hostname2(ro,sync)
 #
 # Example for NFSv4:
 # /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt)
 # /srv/nfs4/homes  gss/krb5i(rw,sync)
 #
 /home/cevin/nfs *(rw,sync,no_root_squash)    注)这里*号前面有空格

解释一下:

# 后面的都是解释

/home/cevin/nfs 是NFS的共享目录,*表示任何IP都可以共享这个目录,你可以改为受限的IP,rw表示的是权限,sync是默认的。

重启NFS服务

sudo /etc/init.d/nfs-kernel-server restart //重启nfs服务
进行测试 尝试一下挂载本地磁盘,将/home/cevin/nfs 挂载到/mnt

root@bkjia.com:/# mount -t nfs 192.168.0.110:/home/cevin/nfs mnt/  //192.168.0.110是你自己的IP
运行 df 看看结果:

root@bkjia.com:/# df
192.168.0.110:/home/cevin/nfs
                     19737280   2962304  15772352  16% /mnt


已经挂载成功了,测试成功,卸载掉

root@bkjia.com:/# umount mnt/

相关内容