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,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
/work/nfs_root *(rw,sync,no_root_squash)
/work/nfs_root/first_fs *(rw,sync,no_root_squash)
book@www.100ask.org:/work/nfs_root/first_fs$ sudo /etc/init.d/nfs-kernel-server restart
[ ok ] Restarting nfs-kernel-server (via systemctl): nfs-kernel-server.service.
book@www.100ask.org:/work/nfs_root/first_fs$
、
# ifconfig eth0 up
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:60:6E:33:44:55
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11880 (11.6 KiB) TX bytes:0 (0.0 B)
Interrupt:51 Base address:0xa000
# ifconfig eth0 192.168.0.11
# ping 192.168.0.106
PING 192.168.0.106 (192.168.0.106): 56 data bytes
64 bytes from 192.168.0.106: seq=0 ttl=64 time=14.726 ms
64 bytes from 192.168.0.106: seq=1 ttl=64 time=0.821 ms
64 bytes from 192.168.0.106: seq=2 ttl=64 time=0.831 ms
64 bytes from 192.168.0.106: seq=3 ttl=64 time=0.827 ms
64 bytes from 192.168.0.106: seq=4 ttl=64 time=7.238 ms
在服务器上自己测试一下
book@www.100ask.org:~$ sudo mount -t nfs 192.168.0.106:/work/nfs_root/first_fs /mnt
book@www.100ask.org:~$ ls /mnt
bin dev etc first_drv.ko hello.txt lib linuxrc proc sbin sys usr
29 packets transmitted, 29 packets received, 0% packet loss
round-trip min/avg/max = 0.661/2.401/14.726 ms
# ls
bin etc linuxrc proc sys
dev lib lost+found sbin usr
# mkdir /mnt
# mount -t nfs -o nolock 192.168.0.106:/work/nfs_root/first_fs /mnt# ls /mnt
bin etc linuxrc sbin usr
dev lib proc sys