在 Ubuntu 上裝載 File Storage for Classic
使用這些指示將 Ubuntu Linux®-based IBM Cloud® Compute instance 連接到 Network File System ( NFS ) 共用。 如需有關如何訂購 IBM Cloud® File Storage for Classic 的詳細資訊,請參閱 入門 教學。
開始之前,請確定要存取 File Storage for Classic 磁碟區的主機已獲得授權。 有關更多信息,請參閱 在控制台授權主機從 CLI 授權主機使用 Terraform 授權主機。
裝載 File Storage for Classic 共用
-
更新與升級發行版:
apt update && apt upgrade -
安裝必要的工具。
apt-get install nfs-common -
建立一個名為
/mnt/nfs的目錄。mkdir -p /mnt/nfs -
重新啟動您的實例:
reboot -
裝載遠端共用。
mount -t nfs -o <options> <host:/mount_point> /mntstorage_as_a_service磁區的範例。#mount -t nfs -o nfsvers=3 fsf-wdc0403a-fz.service.softlayer.com:/IBM02SEV1414935_66/data01 /mntenterprise磁區的範例。# mount -t nfs -o nfsvers=3 nfshou0201d-fz.service.softlayer.com:/IBM01SEV1414935_2 /mnt掛載點資訊可從主控台中的 File Storage for Classic 詳細資訊頁面、API 呼叫 -
SoftLayer_Network_Storage::getNetworkMountAddress()或在 Terraform 中查看ibm_storage_file資源取得。 -
使用磁碟檔案系統指令來驗證裝載是否成功。
# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda2 25G 1.4G 22G 6% / /tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/xvda1 97M 51M 42M 55% -
移至裝載點,並讀寫檔案。
# touch /mnt/test # ls -la /mnt total 12 drwxr-xr-x 2 nobody nobody 4096 Sep 8 15:52 . dr-xr-xr-x. 22 root root 4096 Sep 8 14:30 .. -rw-r--r-- 1 nobody nobody 0 Sep 8 15:52 test -
透過編輯檔案系統表格 (
/etc/fstab),使配置持續保存。將遠端共用新增至啟動時自動裝載的項目清單:sudo nano /etc/fstab將具有下列語法的行新增至檔案結尾。
(hostname):/(mount_point) /mnt nfs_version defaults 0 0範例
nfsdal1301a.service.softlayer.com:/IBM01SV278685_7 /mnt nfsvers=3 defaults 0 0 -
驗證配置檔未發生錯誤。
# mount -fav如果指令完成且沒有任何錯誤,則設定已完成。
如果您使用 NFS 4.1,請將
sec=sys新增至 mount 指令,以防止發生檔案所有權問題。
管理使用者對掛載檔案共用內容的權限
身為系統管理員,您可以管理掛載檔案儲存卷上資料的存取權。 掛載檔案共用後,您可以使用 chown 和 chmod 指令為個別使用者和群組指定讀取、寫入和執行權限,從而完善存取控制。 如需詳細資訊,請參閱 Ubuntu Server 有關使用者管理的說明文件。
解除裝載檔案系統
若要在您的主機上解除裝載任何目前已裝載的檔案系統,請用磁碟名稱或裝載點名稱執行 umount 指令。
umount /dev/sdb
umount /mnt