ubuntu16.04
安裝nfs服務
如果用: apt-get install nfs-kernel-server portmap安裝後會自動運行
打開/etc/exports文件,在末尾加入:
/ * 保存(注意/ * 之間有空格)
注:/etc/exports爲NFS服務器的配置文件,"/ *"是掛載根目錄下的所有文件
執行下面重啓NFS服務
/etc/init.d/nfs-kernel-server restart
注:nfs允許掛載的目錄及權限,在文件/etc/exports中進行定義,各字段含義如下:
/home/ *(rw,sync,no_root_squash)
/home/:要共享的目錄
* :允許所有的網段訪問
rw :讀寫權限
sync:資料同步寫入內在和硬盤
no_root_squash:nfs客戶端共享目錄使用者權限
本機掛載測試
取消掛載
umount /mnt
linux內核配置
[*] Networking support --->
Networking options --->
[*] IP: kernel level autoconfiguration
當然還需要啟動NFS的功能。
File systems --->
[*] Network File Systems --->
<*> NFS client support
[*] Root file system on NFS
5.3.2 網絡功能設置
TCP/IP 設置
要使能基本的網絡功能, 請依照以下設置即可.
[*] Networking support --->
Networking options --->
<*> Packet socket
<*> Unix domain sockets
[*] TCP/IP networking
[*] IP: multicasting
保存->編譯->燒錄->啓動
~ # ifconfig eth0 192.168.0.4 up
nuc970-emac0 nuc970-emac0: eth0 is OPENED
~ # ping 192.168.0.199
PING 192.168.0.199 (192.168.0.199): 56 data bytes
64 bytes from 192.168.0.199: seq=0 ttl=64 time=2.342 ms
64 bytes from 192.168.0.199: seq=1 ttl=64 time=1.092 ms
^C
--- 192.168.0.199 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 1.092/1.717/2.342 ms
掛載出錯
~ # mount 192.168.0.199: /tmp
svc: failed to register lockdv1 RPC service (errno 5).
lockd_up: makesock failed, error=-5
mount: mounting 192.168.0.199: on /tmp failed: Input/output error
~ # mount 192.168.0.199:/home/hbin/nfs /tmp
svc: failed to register lockdv1 RPC service (errno 5).
mount: mounting 192.168.0.199:/home/hbin/nfs on /tmp failed: Input/output error
~ #
~ # mount 192.168.0.199:/home /tmp
svc: failed to register lockdv1 RPC service (errno 5).
mount: mounting 192.168.0.199:/home on /tmp failed: Input/output error
掛載成功
~ # mount -t nfs -o nolock 192.168.0.199:/home /tmp
~ # cd tmp
/tmp # cd hbin
/tmp/hbin # ls
Desktop Pictures examples.desktop nuc977_bsp
Documents Public log print kernel.txt
Downloads Templates nfs test.txt
Music Videos nuc
/tmp/hbin # umount /tmp
umount: can't umount /tmp: Device or resource busy
退出tmp目錄
mount -t nfs -o nolock 192.168.0.199:/home/hbin/nfs /mnt