第三步 安装配置nfs服务器

1 安装
root@ubuntu:/# apt-get install nfs-common nfs-kernel-server nfs-client
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
Reading state information... 完成
nfs-common 已经是最新的版本了。
nfs-kernel-server 已经是最新的版本了。
注意,我选了 nfs-common 而非 nfs-client
nfs-common 已经是最新的版本了。
共升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件未被升级。

2 配置
root@ubuntu:~# nano /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/cache/netboot 192.168.1.0/24(rw,no_root_squash,sync)
注*上面这一行是服务器端提供的磁盘空间的位置,可以是服务器的任一目录,建议将一个单独的磁盘分区挂在这个目录下。但是请注意:这个服务器端的/home/cache/netboot并不是将来客户端的虚拟根目录,因为在/home/cache/netboot下面将会有一个名为root的子目录,而这个/home/cache/netboot/root才是本文中的客户端的虚拟根目录,在启动完成后、实际运行过程中,工作就仅局限在/home/cache/netboot/root中了。建立root的问题下文将会讲到)

3 启动nfs或者重新加载
启动nfs
root@ubuntu:/# /etc/init.d/nfs-kernel-server start
* Exporting directories for NFS kernel daemon...
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.1.0/24:/home/cache/netboot".
Assuming default behaviour ('no_subtree_check').
NOTE: this default has changed since nfs-utils version 1.0.x
...done.
* Starting NFS kernel daemon
...done.
如果是修改了/etc/exports 配置文件,不需要重新启动nfs服务器,只需要刷新一下,命令如下
root@ubuntu:/# exportfs -r
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.1.0/24:/home/cache/netboot".
Assuming default behaviour ('no_subtree_check').
NOTE: this default has changed since nfs-utils version 1.0.x


相关内容