【Azure 儲存服務】如何把開啟NFS 3.0協議的Azure Blob掛載在Linux VM中呢?(NFS: Network File System 網路檔案系統)

路邊兩盞燈發表於2021-11-04

問題描述

如何把開啟NFS協議的Azure Blob掛載到Linux虛擬機器中呢?

【答案】:可以使用 NFS 3.0 協議從基於 Linux 的 Azure 虛擬機器 (VM) 或在本地執行的 Linux 系統,在 Blob 儲存中裝載容器 

 

操作步驟

參考官方文件(Mount Blob storage by using the Network File System (NFS) 3.0 protocol: https://docs.microsoft.com/en-us/azure/storage/blobs/network-file-system-protocol-support-how-to )可以成功的讓 NFS 3.0的Blob Mount到VM中。

【Azure 儲存服務】如何把開啟NFS 3.0協議的Azure Blob掛載在Linux VM中呢?(NFS: Network File System 網路檔案系統)

 

準備條件:

1) 開啟NFS的Azure Storage Account

2) Linux 虛擬機器(本示例中使用的為 UbuntuServer 18.04-LTS)

3) Storage Account與Linux 處於同一虛擬網路中,並且在Storage Account中設定允許訪問的子網。

 

注意事項:

1)在建立Storage Account的時候要先開啟ADLS Gen 2.0 (即Enable Hierarchical namespace 和 Enable network file system v3)

【Azure 儲存服務】如何把開啟NFS 3.0協議的Azure Blob掛載在Linux VM中呢?(NFS: Network File System 網路檔案系統)

 

2) 使用PuTTy,SSH登入到VM後,需要使用用root許可權執行mount命令。 使用 sudo -i 切換到root目錄中。同時,如果沒有安裝nfs helper會提示bad option訊息。只需使用 sudo apt install nfs-common 安裝nfs helper。

【Azure 儲存服務】如何把開啟NFS 3.0協議的Azure Blob掛載在Linux VM中呢?(NFS: Network File System 網路檔案系統)

 

 3)最終,使用正確的 Storage Account 和 Container 名稱替換下面指令中的資訊。

mkdir -p /mnt/test

mount -o sec=sys,vers=3,nolock,proto=tcp <storage-account-name>.blob.core.chinacloudapi.cn:/<storage-account-name>/<container-name>  /mnt/test


#1: Replace the <storage-account-name> placeholder that appears in this command with the name of your storage account.

#2:Replace the <container-name> placeholder with the name of your container.

【Azure 儲存服務】如何把開啟NFS 3.0協議的Azure Blob掛載在Linux VM中呢?(NFS: Network File System 網路檔案系統)

 

如果遇見錯誤,可以參考文件後面的常見錯誤部分,在本次的實驗中,就先後遇見了 Access denied by server while mounting 和 mount: /mnt/test: bad option;錯誤。

ErrorCause / resolution
Access denied by server while mounting Ensure that your client is running within a supported subnet. See the Supported network locations.
No such file or directory Make sure to type the mount command and it's parameters directly into the terminal. If you copy and paste any part of this command into the terminal from another application, hidden characters in the pasted information might cause this error to appear. This error also might appear if the account isn't enabled for NFS 3.0.
Permision denied The default mode of a newly created NFS v3 container is 0750. Non-root users do not have access to the volume. If access from non-root users is required, root user must change the mode to 0755. Sample command: sudo chmod 0755 /mnt/<newcontainer>
EINVAL ("Invalid argument") This error can appear when a client attempts to:
  • Write to a blob that was created from a blob endpoint.
  • Delete a blob that has a snapshot or is in a container that has an active WORM (Write Once, Read Many) policy.
EROFS ("Read-only file system") This error can appear when a client attempts to:
  • Write to a blob or delete a blob that has an active lease.
  • Write to a blob or delete a blob in a container that has an active WORM (Write Once, Read Many) policy.
NFS3ERR_IO/EIO ("Input/output error") This error can appear when a client attempts to read, write, or set attributes on blobs that are stored in the archive access tier.
OperationNotSupportedOnSymLink error This error can be returned during a write operation via a Blob or Azure Data Lake Storage Gen2 API. Using these APIs to write or delete symbolic links that are created by using NFS 3.0 is not allowed. Make sure to use the NFS v3 endpoint to work with symbolic links.
mount: /mnt/test: bad option; Install the nfs helper program using sudo apt install nfs-common.

 

參考文件

Mount Blob storage by using the Network File System (NFS) 3.0 protocol:https://docs.microsoft.com/en-us/azure/storage/blobs/network-file-system-protocol-support-how-to

 

相關文章