樹心幽徑

« 20190117在fedora裝gcc7.4成功 | Main | 20190118製作Fedora Server’s netinst images隨身碟(一個16GB的USB隨身碟才175元)成功 »

20190117在ubuntu1604裝nfsserver成功
2019/01/17,19:57

ref :http://flykof.pixnet.net/blog/post/23028290-ubunto%E4%B8%8B%E5%AE%89%E8%A3%9D%E8%A8%AD%E5%AE%9Anfs

 

(1)$ sudo apt-get install nfs-kernel-server

:

  keyutils libnfsidmap2 libtirpc1 nfs-common rpcbind
建議套件:
  open-iscsi watchdog
下列【新】套件將會被安裝:
  keyutils libnfsidmap2 libtirpc1 nfs-common nfs-kernel-server rpcbind
升級 0 個,新安裝 6 個,移除 0 個,有 470 個未被升級。
需要下載 484 kB 的套件檔。
此操作完成之後,會多佔用 1,828 kB 的磁碟空間。
是否繼續進行 [Y/n]? [Y/n] y

取得 484 kB 用了 2秒 (163 kB/s)          
選取了原先未選的套件 libnfsidmap2:i386。
(讀取資料庫 ... 目前共安裝了 325945 個檔案和目錄。)
準備解開 .../libnfsidmap2_0.25-5_i386.deb ...
解開 libnfsidmap2:i386 (0.25-5) 中...
選取了原先未選的套件 keyutils。
準備解開 .../keyutils_1.5.9-8ubuntu1_i386.deb ...
解開 keyutils (1.5.9-8ubuntu1) 中...
選取了原先未選的套件 libtirpc1:i386。
準備解開 .../libtirpc1_0.2.5-1ubuntu0.1_i386.deb ...
解開 libtirpc1:i386 (0.2.5-1ubuntu0.1) 中...
選取了原先未選的套件 rpcbind。
準備解開 .../rpcbind_0.2.3-0.2_i386.deb ...
解開 rpcbind (0.2.3-0.2) 中...
選取了原先未選的套件 nfs-common。
準備解開 .../nfs-common_1%3a1.2.8-9ubuntu12.1_i386.deb ...
解開 nfs-common (1:1.2.8-9ubuntu12.1) 中...
選取了原先未選的套件 nfs-kernel-server。
準備解開 .../nfs-kernel-server_1%3a1.2.8-9ubuntu12.1_i386.deb ...
解開 nfs-kernel-server (1:1.2.8-9ubuntu12.1) 中...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for systemd (229-4ubuntu21.2) ...
Processing triggers for ureadahead (0.100.0-19) ...
ureadahead will be reprofiled on next reboot
設定 libnfsidmap2:i386 (0.25-5) ...
設定 keyutils (1.5.9-8ubuntu1) ...
設定 libtirpc1:i386 (0.2.5-1ubuntu0.1) ...
設定 rpcbind (0.2.3-0.2) ...
設定 nfs-common (1:1.2.8-9ubuntu12.1) ...

Creating config file /etc/idmapd.conf with new version

Creating config file /etc/default/nfs-common with new version
增加系統使用者 `statd' (UID 122) ...
正在新增新使用者 `statd' (UID 122) 到群組 `nogroup' ...
不會建立家目錄 `/var/lib/nfs' 。
nfs-utils.service is a disabled or a static unit, not starting it.
設定 nfs-kernel-server (1:1.2.8-9ubuntu12.1) ...

Creating config file /etc/exports with new version

Creating config file /etc/default/nfs-kernel-server with new version
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for systemd (229-4ubuntu21.2) ...
Processing triggers for ureadahead (0.100.0-19) ...

 

 

(2)$ sudo vi /etc/hosts.deny
treehrt ~$ cat /etc/hosts.deny
# /etc/hosts.deny: list of hosts that are _not_ allowed to access the system.
#                  See the manual pages hosts_access(5) and hosts_options(5).
#
# Example:    ALL: some.host.name, .some.domain
#             ALL EXCEPT in.fingerd: other.host.name, .other.domain
#
# If you're going to protect the portmapper use the name "rpcbind" for the
# daemon name. See rpcbind(8) and rpc.mountd(8) for further information.
#
# The PARANOID wildcard matches any host whose name does not match its
# address.
#
# You may wish to enable this to ensure any programs that don't
# validate looked up hostnames still leave understandable logs. In past
# versions of Debian this has been the default.
# ALL: PARANOID

portmap:ALL
lockd:ALL
mountd:ALL
rquotad:ALL
statd:ALL
treehrt ~$

(3)$ vi /etc/default/portmap

(4)$ sudo vi /etc/hosts.allow
$ cat /etc/hosts.allow
# /etc/hosts.allow: list of hosts that are allowed to access the system.
#                   See the manual pages hosts_access(5) and hosts_options(5).
#
# Example:    ALL: LOCAL @some_netgroup
#             ALL: .foobar.edu EXCEPT terminalserver.foobar.edu
#
# If you're going to protect the portmapper use the name "rpcbind" for the
# daemon name. See rpcbind(8) and rpc.mountd(8) for further information.
#
### NFS DAEMONS
portmap: 192.168.2.
lockd: 192.168.2.
rquotad: 192.168.2.
mountd: 192.168.2.
statd: 192.168.2.
treehrt ~$

(5)$ sudo vi /etc/exports
$ cat /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)
#
/home/treehrt/busyboxRoot 192.168.2.*(rw,sync,no_root_squash)

$ pwd
/home/treehrt

 

(6)$ sudo exportfs -r
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "203.68.230.*:/home/treehrt/busyboxRoot".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: Failed to stat /home/treehrt/busyboxRoot: No such file or directory
treehrt ~$

(7)$ mkdir busyboxRoot

(8)$ sudo exportfs -r
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.2.*:/home/treehrt/busyboxRoot".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

(9)
$ sudo /etc/init.d/nfs-kernel-server restart
[ ok ] Restarting nfs-kernel-server (via systemctl): nfs-kernel-server.service.
 

(10)$ mkdir /home/treehrt/nfs
(11)$ sudo mount -t nfs 192.168.2.100:/home/treehrt/busyboxRoot /home/treehrt/nfs

(12) 將png圖檔拷到/home/treehrt/nfs中,也出現在/home/treehrt/busyboxRoot中

$ cp Firefox_wallpaper.png /home/treehrt/nfs

$ ls /home/treehrt/nfs
Firefox_wallpaper.png

$ ls /home/treehrt/busyboxRoot/ -l
總計 3664
-rw-rw-r-- 1 treehrt treehrt 3749769  1月 17 20:19 Firefox_wallpaper.png


迴響

 
Accessible and Valid XHTML 1.0 Strict and CSS Powered by LifeType