閱讀423 返回首頁    go 阿裏雲 go 技術社區[雲棲]


Ubuntu 11.04 NFS 配置

安裝 NFS 相關組件

sudo apt-get install nfs-kernel-server

增加 NFS 目錄

sudo gedit /etc/exports

#在文件中添加如下內容
/var/nfsboot    *(rw,sync)

/var/nfsboot 為 NFS 共享目錄,可自由指定

× 表示任意的 IP 地址都可以掛載此目錄,若設置為 192.168.1.× 則表示隻有在 192.168.1.??? 這個網段的 IP 才可以掛載

rw                           可讀寫的權限
ro                           隻讀的權限
no_root_squash     NFS 客戶端分享目錄使用者的權限,即如果客戶端使用的是 root 用戶,那麼對於這個共享的目錄而言,該客戶端就具有 root 的權限,若是以NFS掛載根文件係統時,必須設置此項

sync                       資料同步寫入到內存與硬盤當中
async                     資料會先暫存於內存當中,而非直接寫入硬盤

服務操作指令

複製代碼
# 停止
sudo /etc/init.d/nfs-kernel-server stop
# 啟動
sudo /etc/init.d/nfs-kernel-server start
# 重新啟動
sudo /etc/init.d/nfs-kernel-server restart
複製代碼

測試

複製代碼
# 將 /var/nfsboot 目錄掛在在 /mut 下
# 掛載成功後可用 df 命令查看
sudo mount 192.168.1.10:/var/nfsboot /mnt
# 在嵌入式中掛載
sudo mount -o nolock 192.168.1.10:/var/nfsboot /mnt
# 移除掛載目錄
sudo umount /mnt
複製代碼

注意:

  1.完成後如出現 access denied 異常,重新啟動係統即可

  2.在 ubuntu 11.10 中啟動 nfs 服務時會遇到

     * Not starting: portmapper is not running

解決方法:

sudo service portmap restart
sudo /etc/init.d/nfs-kernel-server start
2012-04-24 21:46

mount.nfs: access denied by server while mounting 一個解決辦法

I googled and found that since the port is over 1024 I needed to add the "insecure" option to the relevant line in /etc/exports on the server. Once I did that (and ran exportfs -r), the mount -a on the client worked.

//如果端口號大於1024,則需要將 insecure 選項加入到配置文件(/etc/exports)相關選項中mount客戶端才能正常工作:

查看 exports 手冊中關於 secure 選項說明也發現確實如此

[root@lzgonline init.d]# man exports

secure,This  option requires that requests originate on an Internet port less than IPPORT_RESERVED (1024). This option is on by default. To turn it off, specify insecure.

//secure 選項要求mount客戶端請求源端口小於1024(然而在使用 NAT 網絡地址轉換時端口一般總是大於1024的),默認情況下是開啟這個選項的,如果要禁止這個選項,則使用 insecure 標識

修改配置文件/etc/exports,加入 insecure 選項

/home/lzgonline/rootfs  *(insecure,rw,async,no_root_squash)

保存退出

然後重啟nfs服務:service nfs restart

然後問題就解決了


https://hi.baidu.com/alizee635_2012/item/a8c4d371f3bd7042ee1e53ec

最後更新:2017-04-03 16:48:42

  上一篇:go JAVA的helloworld
  下一篇:go GM8180啟動過程調試