IBM Cloud Docs
创建文件共享和安装目标

创建文件共享和安装目标

在控制台、CLI、API 或 Terraform 中创建文件共享和挂载目标。

在开始之前,尝试为文件共享创建安装目标,请确保已创建 VPC

您可以通过以下任一方式创建文件共享和安装目标:

  • 创建文件共享并一起挂载目标、
  • 创建文件共享并稍后添加安装目标。

创建安装目标时,其传输加密类型必须反映共享的允许传输加密方式。 如果要由不同 VPC 中的资源使用,那么可以为共享创建多个安装目标。 每个 VPC 可为文件共享创建一个挂载目标。

拥有预览新区域文件共享产品特殊权限的客户可以使用 rfs 配置文件创建具有区域可用性和可调带宽值的文件共享。

在控制台中创建文件共享

在 IBM Cloud 控制台中,可以创建具有或不具有安装目标的文件共享。 但是,当您要在虚拟服务器实例上安装共享时,需要创建安装目标。

在控制台中创建文件共享

  1. IBM Cloud 控制台中,单击导航菜单图标菜单图标 > 基础架构 VPC 图标 > 存储 > 文件存储共享。 将显示文件共享的列表。

  2. 在 VPC 的文件存储共享页面上,单击创建。 选择创建文件共享

  3. 输入以下信息。

    创建文件共享的值
    字段
    可用性 Beta 如果您是拥有特殊权限的客户,可以预览新的区域文件共享服务,您可以在区域和单区数据可用性之间进行选择。 创建共享后不能更改此属性。
    如果您的账户未被列入允许列表,则不会显示此字段。 选择分区文件共享的位置。
    地区 Beta 如果选择“单区可用性”,请为新文件共享选择地理位置、区域和区,例如,北美、达拉斯 (美国南部)、us-south-2。 如果选择地区可用性,请选择地区。 例如,达拉斯(美国南部)。
    详细信息
    名称 为文件共享指定一个有意义的名称。 文件共享名称最多可以是 63 个小写字母数字字符,并且包含连字符 (-),并且必须以小写字母开头。 如果需要,您日后可以编辑该名称。
    资源组 使用缺省资源组或指定 资源组。 资源组帮助组织帐户资源,以进行访问控制和计费。
    标记(可选) 输入要应用于此文件共享的任何用户标记。 在您输入时,将显示您可以选择的现有标记。 有关标记的更多信息,请参阅 将用户标记添加到文件共享
    访问管理标记(可选) 输入您在 IAM 中创建的访问管理标记,以将其应用于此文件共享。 有关访问管理标记的更多信息,请参阅 文件共享的访问管理标记
    Profile

    配置文件将根据您的数据可用性选择自动填充。 有关详细信息,请参阅文件存储预案

    • 如果选择单区可用性,文件共享将使用 dp2 配置文件。 选择文件共享的大小和 IOPS。 您可以稍后增加容量,也可以根据需要调整 IOPS。
    • Beta 如果选择区域可用性,文件共享将使用 rfs 配置文件。 选择文件共享的大小和带宽。 您可以在以后增加容量,也可以根据需要调整带宽。
    安装目标访问方式 选择要如何管理对此文件共享的访问权:
    安全组: 对文件共享的访问基于 安全组 规则。 此选项可用于限制对特定虚拟服务器实例的访问。 如果要将文件共享安装到另一个区域中的虚拟服务器实例,那么也可以使用此选项。 建议使用此选项,因为您可以更好地控制谁可以访问存储在文件共享上的数据。 选择这种访问类型时,还可以指定允许的传输加密模式。
    虚拟私有云: 向同一区域中的任何虚拟服务器实例授予对文件共享的访问权。 选择此访问模式时,不支持跨区域安装、传输加密、跨区域安装和快照。 Beta 区域共享不支持这种传统访问模式。
    允许的传输加密模式 作为共享所有者,您可以指定希望帐户和授权帐户中的客户机如何连接到文件共享。 如果不想在传输过程中使用加密,可以选择“”。 如果希望它们在传输过程中使用加密,请为区域共享选择用户管理,或为区域共享选择 Beta stunnel。 如果同时选择两个可用选项,则第一个挂载目标的传输加密类型将决定账户内所有未来挂载目标的传输加密类型。
  4. 安装目标的创建是可选的。 如果您现在不想创建安装目标,那么可以跳过此步骤。 否则,单击“创建”。 您可以为每个文件共享创建一个安装目标。

    • 如果选择了安全组作为访问方式,请按表 2 中所述输入信息。 此操作将创建 虚拟网络接口 并将其连接到安装目标,以标识具有保留 IP 地址的文件共享并应用所选安全组的规则。 此安装目标支持传输中加密和跨区域安装。

      1. 提供安装目标名称。 该名称最多可以是 63 个小写字母数字字符,并且包含连字符 (-),并且必须以小写字母开头。 如果需要,您日后可以编辑该名称。
      2. 选择可用的 VPC。 该列表只包括在所选位置有子网的 VPC。 位置选择是从文件共享继承的(例如 us-south-2 )。
      3. 生成一个默认虚拟网络接口。 点击“编辑”图标即可对其进行自定义。 如果区域中有多个子网,那么可以更改名称或子网。
      4. 单击下一步
      5. 对于区域共享,传输中加密默认处于禁用状态;对于区域共享,传输中加密默认处于启用状态。 单击切换按钮更改预设值。 有关此功能的更多信息,请参阅 在传输中加密-保护文件共享与主机之间的安装连接
      6. 然后,单击下一步
      7. 复审您的选择,然后单击 上一步 以返回并更新您的选择,或者单击 创建
    • 如果选择了 VPC 作为访问方式,请提供安装目标的名称,然后从列表中选择 VPC。 此安装目标可用于在与文件共享相同的区域中所选 VPC 的任何虚拟服务器实例上安装文件共享。 不支持跨区域安装。

  5. 静态加密。 缺省情况下,所有文件共享都由 IBM管理的密钥加密。 您还可以选择使用自己的密钥为共享创建包络加密。 如果要使用自己的密钥,请选择其中一个 密钥管理服务

    客户管理的文件共享加密值。
    字段
    加密 要使用客户管理的加密,请选择 Key Protect 或 Hyper Protect Crypto Services。 密钥管理服务 (KMS) 实例包含导入到该 KMS 实例或在该 KMS 实例中创建的根密钥。
    加密服务实例 如果在账户中配置了多个 KMS 实例,请选择包含要用于客户管理加密的根密钥的实例。
    密钥名称 在 KMS 实例中选择要用于加密共享的根密钥。
    密钥标识 该字段显示与所选数据加密密钥相关的密钥 ID。
  6. 输入所有必需信息后,单击 创建文件共享。 返回到 File Storage for VPC 页面,其中有一条消息指示正在供应文件共享。 事务完成时,共享状态将更改为 活动

如果您尚未准备好订购或仅查找定价信息,那么可以将在侧面板中看到的信息添加到估算中。 有关此功能的工作方式的更多信息,请参阅 估算成本

在控制台中创建挂载目标

  1. IBM Cloud 控制台中,单击导航菜单图标菜单图标 > 基础架构 VPC 图标 > 存储 > 文件存储共享

  2. 从列表中选择文件共享。

  3. 在“文件共享详细信息”页面上的“安装目标”下,单击 创建

    必须至少有一个 VPC 才能创建挂载目标。 如果没有 VPC,请首先 创建 VPC

  4. 根据共享的 安装目标访问方式创建安装目标 表单看起来不同。

    • 如果共享具有安全组访问方式,请输入以下信息。 此操作将创建 虚拟网络接口 并将其连接到安装目标,该接口标识具有保留 IP 地址的文件共享,并应用所选 安全组 的规则。 此安装目标支持传输中加密和跨区域安装。

      1. 提供安装目标名称。 该名称最多可以是 63 个小写字母数字字符,并且包含连字符 (-),并且必须以小写字母开头。 如果需要,您日后可以编辑该名称。
      2. 选择可用的 VPC。 该列表只包括在所选位置有子网的 VPC。 位置选择是从文件共享继承的(例如 us-south-2 )。
      3. 生成一个默认虚拟网络接口。 点击“编辑”图标即可对其进行自定义。 如果您在该位置有多个子网,可以更改名称或子网。
      4. 单击下一步
      5. 对于区域共享,传输中加密默认处于禁用状态;对于区域共享,传输中加密默认处于启用状态。 单击切换按钮更改预设值。 有关此功能的更多信息,请参阅 在传输中加密-保护文件共享与主机之间的安装连接
      6. 然后,单击下一步
    • 如果分区共享的访问模式是 VPC,请提供挂载目标的名称,并从列表中选择一个 VPC。 此安装目标可用于在与文件共享相同的区域中所选 VPC 的任何虚拟服务器实例上安装文件共享。 不支持跨区域安装。

  5. 单击创建

从 CLI 创建文件共享

准备工作

在使用 CLI 之前,您必须安装 IBM Cloud CLI 和 VPC CLI 插件。 有关更多信息,请参阅 CLI 先决条件

如果客户拥有预览区域文件共享配置文件的特殊权限,则可以使用 rfs 配置文件来创建文件共享。 要访问测试版功能,必须使用以下命令设置相应的环境变量。

export IBMCLOUD_IS_FEATURE_SHARE_DENALI_REGIONAL_AVAILABILITY=true

只有当该环境变量设置为 "true "时,CLI 才会返回“允许的访问协议”、“可用性模式”、“带宽”和“存储生成”的属性。

从 CLI 收集信息

在运行 ibmcloud is share-create 命令之前,您可以通过查看有关其他文件共享,安装目标和文件存储器概要文件的信息来收集供应共享所需的信息。

创建文件共享的详细信息。
详细信息 列出选项 它提供的内容
文件共享 ibmcloud is shares 列出区域内的所有股份。
文件共享详细信息 ibmcloud is share SHARE_ID 查看共享的详细信息。
文件共享快照 ibmcloud is share-snapshots 列出区域内可用的快照。
文件共享概要文件 ibmcloud is share-profiles 列出区域内的所有文件共享配置文件。 只能使用 dp2 来创建文件共享。
安装目标 ibmcloud is share-mount-targets SHARE_ID 列出文件共享的所有挂载目标。
子网 ibmcloud is subnets 列出所有子网。
保留的 IP 地址 ibmcloud is subnet-reserved-ips 列出子网中所有保留的 IP 地址。
安全组 ibmcloud is security-groups 列出所有安全组。

使用 CLI 创建无挂载目标的区域文件共享

您可以使用 ibmcloud is share-create 命令,在所选区域内使用 dp2 配置文件,以特定容量和 IOPS 值配置区域文件共享。 下面的示例显示了如何在 us-south-1 区域创建 IOPS 为 100 的 40GB 文件共享。 此文件共享是使用缺省安全组访问方式和提供者管理的加密创建的。

ibmcloud is share-create --name my-file-share --zone us-south-1 --profile dp2 --size 40 --iops 100
Creating file share my-file-share under account Test Account as user test.user@ibm.com...

ID                                 r006-a08c2505-b933-4dce-a771-efff2e1a59e1   
Name                               my-file-share   
CRN                                crn:v1:bluemix:public:is:us-south-1:a/a1234567::share:r006-a08c2505-b933-4dce-a771-efff2e1a59e1   
Lifecycle state                    stable   
Access control mode                security_group   
Accessor binding role              none   
Allowed transit encryption modes   user_managed,none   
Zone                               us-south-1   
Profile                            dp2   
Size(GB)                           40   
IOPS                               100   
Encryption                         provider_managed   
Mount Targets                      ID                          Name      
                                   No mounted targets found.      

Resource group                     ID                                 Name      
                                   6edefe513d934fdd872e78ee6a8e73ef   defaults      

Created                            2025-08-01T20:10:35+00:00   
Replication role                   none   
Replication status                 none   
Replication status reasons         Status code   Status message      
                                   -             -      

Snapshot count                     0   
Snapshot size                      0   
Source snapshot                    -   

测试版 拥有预览区域文件共享产品特殊权限的客户,可以通过首先将环境变量设置为 true 来访问测试版功能。

然后,就可以使用相同的命令创建分区文件共享。 响应显示 ipsec,而不是 user_managed,作为转接加密的允许值。 回复还显示了 Allowed Access Protocols, Availability Mode, BandwidthStorage Generation 属性。

export IBMCLOUD_IS_FEATURE_SHARE_DENALI_REGIONAL_AVAILABILITY=true
ibmcloud is share-create --name my-file-share --zone us-south-1 --profile dp2 --size 40 --iops 100 --allowed-access-protocols nfs4 --atem ipsec,none
Creating file share my-file-share under account Test Account as user test.user@ibm.com...

ID                                 r006-a08c2505-b933-4dce-a771-efff2e1a59e1   
Name                               my-file-share   
CRN                                crn:v1:bluemix:public:is:us-south-1:a/a1234567::share:r006-a08c2505-b933-4dce-a771-efff2e1a59e1   
Lifecycle state                    pending   
Access control mode                security_group   
Accessor binding role              none   
Allowed transit encryption modes   ipsec,none   
Zone                               us-south-1   
Profile                            dp2   
Size(GB)                           40   
IOPS                               100   
Encryption                         provider_managed   
Mount Targets                      ID                          Name      
                                   No mounted targets found.      

Resource group                     ID                                 Name      
                                   6edefe513d934fdd872e78ee6a8e73ef   defaults      

Created                            2025-08-01T20:10:35+00:00   
Replication role                   none   
Replication status                 none   
Replication status reasons         Status code   Status message      
                                   -             -      

Snapshot count                     0   
Snapshot size                      0   
Source snapshot                    -    

安全组访问方式是缺省设置和建议设置。 但是,您可以选择使用 VPC 访问方式创建文件共享,该方式允许 VPC 中的每个计算主机安装文件共享。 请参阅以下示例。

ibmcloud is share-create --name my-vpc-file-share --zone us-south-2 --profile dp2 --size 1000 --iops 500 --access-control-mode vpc
Creating file share my-vpc-file-share under account Test Account as user test.user@ibm.com...

ID                                 r006-83100dcb-24d8-45a6-91f3-256e5c17233f       
Name                               my-vpc-file-share   
CRN                                crn:v1:bluemix:public:is:us-south-2:a/efe5afc483594adaa8325e2b4d1290df::share:r006-83100dcb-24d8-45a6-91f3-256e5c17233f    
Lifecycle state                    pending   
Access control mode                vpc   
Accessor binding role              none
Allowed transit encryption modes   user_managed,none
Zone                               us-south-2   
Profile                            dp2   
Size(GB)                           1000   
IOPS                               500  
Encryption                         provider_managed   
Mount Targets                      ID                                 Name      
                                   No mounted targets found.      

Resource group                     ID                                 Name      
                                   11caaa983d9c4beb82690daab08717e9  Default      

Created                            2025-04-18T19:22:41+00:00   
Replication role                   none   
Replication status                 none   
Replication status reasons         Status code   Status message      
                                   -             -      

Snapshot count                     0   
Snapshot size                      0   
Source snapshot                    -  

使用 CLI 创建无挂载目标的区域文件共享

Beta 拥有预览新区域文件共享产品特殊权限的客户可以使用 rfs 配置文件创建具有区域可用性和可调整带宽值的文件共享。

开始之前,请记住设置环境变量:

export IBMCLOUD_IS_FEATURE_SHARE_DENALI_REGIONAL_AVAILABILITY=true

只有当该环境变量设置为 "true "时,CLI 才会返回“允许的访问协议”、“可用性模式”、“带宽”和“存储生成”的属性。

下面的示例显示了如何创建带宽为 125 Mbps 的 40GB 区域文件共享。 创建此文件共享时采用了安全组访问模式和提供商管理加密。 文件共享将在您登录时选择的区域内创建,无需选择位置。

ibmcloud is share-create --name my-regional-file-share --profile rfs --size 40 --bandwidth 125 --allowed-access-protocols nfs4 --atem stunnel,none
Creating file share my-regional-file-share under account Test Account as user test.user@ibm.com...

ID                                 r006-749d05eb-9779-4414-b902-553a4fd1421d   
Name                               my-regional-file-share   
CRN                                crn:v1:bluemix:public:is:us-south:a/a1234567::share:r006-749d05eb-9779-4414-b902-553a4fd1421d   
Lifecycle state                    pending   
Access control mode                security_group   
Accessor binding role              none   
Allowed transit encryption modes   stunnel,none   
Zone                               -   
Profile                            rfs   
Size(GB)                           40   
IOPS                               35000   
Encryption                         provider_managed   
Mount Targets                      ID                          Name      
                                   No mounted targets found.      

Resource group                     ID                                 Name      
                                   6edefe513d934fdd872e78ee6a8e73ef   defaults      

Created                            2025-08-01T20:20:09+00:00   
Replication role                   none   
Replication status                 none   
Replication status reasons         Status code   Status message      
                                   -             -      

Snapshot count                     -   
Snapshot size                      -   
Source snapshot                    -   
Allowed Access Protocols           nfs4   
Availability Mode                  regional   
Bandwidth(Mbps)                    125   
Storage Generation                 2

安全组访问模式为默认设置。 具有区域可用性的文件共享不支持 VPC 访问模式。

有关命令选项的更多信息,请参阅 ibmcloud is share-create

从 CLI 为文件共享创建安装目标

要为文件共享创建安装目标,请运行 share-mount-target-create 命令。 在开始之前,请收集一些必要的信息。

创建安装目标时,必须指定其用于的文件共享。 您可以使用文件共享的名称或标识。 您还必须指定 VPC 及其标识或名称。 VPC 对于每个安装目标都必须是唯一的。 您还必须指定将用于管理对共享的访问权的安全访问组。 与挂载目标相关联的安全组必须允许从要挂载共享的所有服务器 NFS 端口对 TCP 协议进行入站访问。

最后,必须为为安装目标创建 虚拟网络接口 所需的选项指定值。 使用相应的 CLI 命令来列出可用的 子网子网中的保留 IP 地址安全组,以获取所需的信息。

以下示例为具有安全组访问方式的文件共享创建具有虚拟网络接口的安装目标。

ibmcloud is share-mount-target-create my-file-share --subnet my-subnet --name my-cli-share-mount-target-1 --vni-name my-share-vni-1  --resource-group-id 6edefe513d934fdd872e78ee6a8e73ef  --access-protocol nfs4 --transit-encryption none --vpc my-vpc
Mounting target for share r006-b696742a-92ee-4f6a-bfd7-921d6ddf8fa6 under account Test Account as user test.user@ibm.com...

ID                          r006-72c81658-35ae-40b7-abab-8480e5050857   
Name                        my-cli-share-mount-target-1   
VPC                         ID                                          Name      
                            r006-243394d6-b192-4e05-bfab-5d0b4e77cf81   my-vpc      

Access control mode         security_group   
Resource type               share_mount_target   
Virtual network interface   ID                                          Name             Protocol State Filtering Mode      
                            0717-6dedcf6f-7596-4274-b158-c01f08edb697   my-share-vni-1   auto      

Lifecycle state             pending   
Mount path                  -   
Transit Encryption          none   
Created                     2025-08-01T20:28:50+00:0

Beta 当使用同一命令为区域文件共享创建挂载目标时,输出结果看起来非常相似。 还显示了 Access Protocol 属性。

ibmcloud is share-mount-target-create my-regional-file-share --subnet my-subnet --name my-regional-share-mount-target-1 --vni-name my-share-vni-2  --resource-group-id 6edefe513d934fdd872e78ee6a8e73ef  --access-protocol nfs4 --transit-encryption none --vpc my-vpc
Mounting target for share r006-749d05eb-9779-4414-b902-553a4fd1421d under account Test Account as user test.user@ibm.com...

ID                          r006-bc95a3c2-b84b-4186-8c5a-e3dd220abefa   
Name                        my-regional-share-mount-target-1   
VPC                         ID                                          Name      
                            r006-243394d6-b192-4e05-bfab-5d0b4e77cf81   my-vpc      

Access control mode         security_group   
Resource type               share_mount_target   
Virtual network interface   ID                                          Name             Protocol State Filtering Mode      
                            0717-24e7dcac-e30f-43cf-9bee-3cab93692690   my-share-vni-2   auto      

Lifecycle state             pending   
Mount path                  -   
Transit Encryption          none   
Created                     2025-08-01T20:45:14+00:00   
Access Protocol             nfs4   

下面的示例为具有 VPC 访问模式的区域文件共享创建了一个挂载目标。

ibmcloud is share-mount-target-create my-vpc-file-share --vpc cli-vpc-3 --name my-vpc-mount-target --access-protocol nfs4 --transit-encryption none
Mounting target for share r006-10e82e16-ff7f-4ca4-b543-d24084fc03cf under account Test Account as user test.user@ibm.com...

ID                        r006-71fd953c-8e49-48e8-ab49-5977c324a365   
Name                      my-vpc-mount-target   
VPC                       ID                                          Name      
                          r006-060fbfe6-4d0f-47b0-b9c5-94da8e719e22   cli-vpc-3      

Access control mode       vpc   
Resource type             share_mount_target
Virtual network interface   
Lifecycle state           pending   
Created                   2025-07-22T22:15:15+00:00
Mount path                -    
Transit Encryption        none

有关命令选项的更多信息,请参阅 ibmcloud is share-mount-target-create

从 CLI 创建与安装目标的文件共享

您可以使用 ibmcloud is share-create 命令在一个步骤中创建与一个或多个安装目标的文件共享。 您需要提供区域名称,文件共享概要文件,文件共享大小和 IOPS。 您还可以指定名称,用户标记,甚至初始所有者 UID。 要创建安装目标,需要提供 JSON 格式的安装目标信息。

下面的示例显示了如何在 us-south-1 区域创建容量为 500 GB、IOPS 为 2000 的区域文件共享。 文件共享使用 env:dev 进行标记,并且具有安全组访问控制方式。 可以使用安装目标 my-new-mount-target 在授权虚拟服务器上安装文件共享。

ibmcloud is share-create --name my-new-file-share --zone us-south-1 --profile dp2 --size 500 --iops 2000 --allowed-transit-encryption-modes user_managed,none --user-tags env:dev --mount-targets '[{"name":"my-new-mount-target","virtual_network_interface": {"name":"my-vni","subnet": {"id":"0717-c66032c9-048d-4c35-aa83-c932e24afdbb"}}}]'
Creating file share my-new-file-share under account Test Account as user test.user@ibm.com...

ID                                 r006-201487a2-cf35-4b2a-a4fe-f480803e1e80   
Name                               my-new-file-share   
CRN                                crn:v1:bluemix:public:is:us-south-1:a/a1234567::share:r006-201487a2-cf35-4b2a-a4fe-f480803e1e80   
Lifecycle state                    pending   
Access control mode                security_group   
Accessor binding role              none   
Allowed transit encryption modes   user_managed,none   
Zone                               us-south-1   
Profile                            dp2   
Size(GB)                           500   
IOPS                               2000   
User Tags                          env:dev   
Encryption                         provider_managed   
Mount Targets                      ID                                          Name      
                                   r006-c8952df9-f479-49a8-a66b-85bf112e0831   my-new-mount-target      

Resource group                     ID                                 Name      
                                   6edefe513d934fdd872e78ee6a8e73ef   defaults      

Created                            2025-08-01T21:17:25+00:00   
Replication role                   none   
Replication status                 none   
Replication status reasons         Status code   Status message      
                                   -             -      

Snapshot count                     0   
Snapshot size                      0   
Source snapshot                    -      

BetaIBMCLOUD_IS_FEATURE_SHARE_DENALI_REGIONAL_AVAILABILITY 变量设置为 true 时,相同命令产生的响应略有不同。

ibmcloud is share-create --name my-new-file-share --zone us-south-1 --profile dp2 --size 500 --iops 2000 --allowed-transit-encryption-modes ipsec,none --user-tags env:dev --mount-targets '[{"name":"my-new-mount-target","virtual_network_interface": {"name":"my-vni","subnet": {"id":"0717-c66032c9-048d-4c35-aa83-c932e24afdbb"}}}]' --initial-owner-gid 101 --initial-owner-uid 10001
Creating file share my-new-file-share under account Test Account as user test.user@ibm.com...

ID                                 r006-201487a2-cf35-4b2a-a4fe-f480803e1e80   
Name                               my-new-file-share   
CRN                                crn:v1:bluemix:public:is:us-south-1:a/a1234567::share:r006-201487a2-cf35-4b2a-a4fe-f480803e1e80   
Lifecycle state                    pending   
Access control mode                security_group   
Accessor binding role              none   
Allowed transit encryption modes   ipsec,none
Zone                               us-south-1   
Profile                            dp2   
Size(GB)                           500   
IOPS                               2000   
User Tags                          env:dev   
Encryption                         provider_managed   
Mount Targets                      ID                                          Name      
                                   r006-c8952df9-f479-49a8-a66b-85bf112e0831   my-new-mount-target      

Resource group                     ID                                 Name      
                                   6edefe513d934fdd872e78ee6a8e73ef   defaults      

Created                            2025-08-01T21:17:25+00:00   
Replication role                   none   
Replication status                 none   
Replication status reasons         Status code   Status message      
                                   -             -      

Snapshot count                     0   
Snapshot size                      0   
Source snapshot                    -      
Allowed Access Protocols           nfs4   
Availability Mode                  zonal   
Bandwidth(Mbps)                    1   
Storage Generation                 1                   

Beta 下面的示例显示了如何通过 CLI 创建带有挂载目标的区域文件共享。 运行命令前,请确保将环境变量设置为 true。 请注意,虽然该命令指定的带宽值较低,但系统会自动校正配置,为每 20 GB 的容量提供至少 8 Mbps 的带宽。

ibmcloud is share-create --name my-regional-file-share --profile rfs --size 5000 --bandwidth 125 --allowed-access-protocols nfs4 --atem stunnel --mount-targets '[{"name":"my-new-mount-target","virtual_network_interface": {"name":"my-regional-vni","subnet": {"id":"0717-c66032c9-048d-4c35-aa83-c932e24afdbb"}}}]'
Creating file share my-regional-file-share under account under account Test Account as user test.user@ibm.com...

ID                                 r006-770ff2f9-3211-459d-918b-fbf0b4a4f999   
Name                               my-regional-file-share   
CRN                                crn:v1:bluemix:public:is:us-south:a/a1234567::share:r006-770ff2f9-3211-459d-918b-fbf0b4a4f999   
Lifecycle state                    pending   
Access control mode                security_group   
Accessor binding role              none   
Allowed transit encryption modes   stunnel   
Zone                               -   
Profile                            rfs   
Size(GB)                           5000   
IOPS                               35000   
Encryption                         provider_managed   
Mount Targets                      ID                                          Name      
                                   r006-f7c84cb2-0e82-4f9e-b729-6e51ea437df6   my-new-mount-target      

Resource group                     ID                                 Name      
                                   6edefe513d934fdd872e78ee6a8e73ef   defaults      

Created                            2025-08-01T21:27:07+00:00   
Replication role                   none   
Replication status                 none   
Replication status reasons         Status code   Status message      
                                   -             -      

Snapshot count                     -   
Snapshot size                      -   
Source snapshot                    -   
Allowed Access Protocols           nfs4   
Availability Mode                  regional   
Bandwidth(Mbps)                    250   
Storage Generation                 2

以下示例创建具有 VPC 访问方式的文件共享以及可供 VPC 中的任何虚拟服务器实例使用的安装目标。

ibmcloud is share-create --name my-file-share-8 --zone us-south-1 --profile dp2 --size 40 --iops 2000 --user-tags env:dev --mount-targets '[{"name": "my-new-mount-target","vpc": {"name": "my-vpc"}}]'
Creating file share my-file-share-8 under account Test Account as user test.user@ibm.com...

ID                           r006-95ec87ba-c5fd-4178-a114-2a55c4d907d4   
Name                         my-file-share-8   
CRN                          crn:v1:bluemix:public:is:us-south-1:a/a1234567::share:r006-95ec87ba-c5fd-4178-a114-2a55c4d907d4   
Lifecycle state              pending   
Access control mode          vpc   
Accessor binding role        none   
Zone                         us-south-1   
Profile                      dp2   
Size(GB)                     40   
IOPS                         2000   
User Tags                    env:dev   
Encryption                   provider_managed   
Mount Targets                ID                                          Name      
                             r006-8b917757-ad19-4bec-8417-83157b047cea   my-new-mount-target      

Resource group               ID                                 Name      
                             6edefe513d934fdd872e78ee6a8e73ef   Default    

Created                      2025-08-01T19:36:35+00:00

Replication role             none   
Replication status           none   
Replication status reasons   Status code   Status message      
                             -             -      

Snapshot count               0   
Snapshot size                0   
Source snapshot              -  

通过 CLI 使用客户管理的加密创建文件共享

缺省情况下,File Storage for VPC 共享使用 IBM管理的加密进行加密。 但是,您还可以使用其中一个受支持的密钥管理服务来创建或导入自己的根密钥,从而为文件共享创建包络加密。 有关更多信息,请参阅 使用包络加密保护数据

有关如何使用客户管理的加密创建文件共享的更多信息,请参阅 使用客户管理的加密创建文件共享

从 CLI 创建与另一个区域中的副本的文件共享

有关如何同时创建与副本的文件共享的更多信息,请参阅 从 CLI 创建与复制的文件共享

具有区域可用性的文件共享可为区域内的每个区域提供数据。 区域内的异步复制不适用于这些共享。

通过 CLI 从快照创建文件共享

您可以使用文件共享快照在同一区域创建另一个文件共享。 要根据快照创建文件共享,请运行 ibmcloud is share-create 命令。

您可以指定快照的名称、ID 或 CRN。 如果选择指定快照的名称,还需要指定快照所属文件共享的名称或 ID。 快照名称在文件共享级别必须是唯一的,但另一个文件共享可以有相同名称的快照。

ibmcloud is share-create --snapshot r026-7647ba64-9728-4bb4-be2f-d958f738fdae

有关如何从快照创建文件共享的详细信息及其他示例,请参阅 从文件共享快照恢复数据

测试版 在测试阶段,不支持具有区域数据可用性的文件共享的快照。 已定义性能配置文件系列中的第一代和第二代文件共享配置文件不能互换。 您不能使用第一代文件共享的快照来创建带有 rfs 配置文件的共享。

使用 CLI 创建文件共享时添加补充 ID

通过 CLI,您可以为 --initial-owner-uid--initial-owner-gid 属性设置 UIDGID 值,以控制对文件共享的访问。 无论您在何处安装文件共享,根文件夹都会使用该用户标识和组标识所有者。 创建共享时,您可以设置 UIDGID,或两者都设置。

如果从虚拟服务器实例更改补充标识 (UID 或 GID),那么无法确定其是否已更改。 因此,initial_owner 只在文件存储系统中发生变化,但变化不会反映在 CLI 或 API 响应中。

表 1 显示了可以设置的 UID 和 GID 值以及保留的值。

Unix/Linux® supplemental ID values.
标识值 描述
UID
UID 0 保留用于 root 用户。
UID 1-99 保留用于预定义帐户。
UID 100-999 由系统为管理系统帐户和组保留。
UID 1000-10000 由应用程序帐户使用。
UID 10000 + 可用于用户帐户。
GID
GID 0 保留用于 root 用户。
GID 1-99 保留供系统和应用程序使用。
100 + GID 已分配给用户的组。

要在创建共享时设置补充 ID,请运行 ibmcloud is share-create 命令,并用补充 ID 指定 --initial-owner-gid--initial-owner-gid 属性。 请参阅以下示例。

ibmcloud is share-create --name my-file-share --zone us-south-2 --profile dp2 --size 1000 --iops 1000 --initial-owner-gid 101 --initial-owner-uid 10001
Creating file share my-file-share under account Test Account as user test.user@ibm.com...

ID                                 r006-bc73917f-b86e-4f6d-b919-6997a88c8031   
Name                               my-file-share   
CRN                                crn:v1:bluemix:public:is:us-south-2:a/a1234567::share:r006-bc73917f-b86e-4f6d-b919-6997a88c8031   
Lifecycle state                    stable   
Access control mode                security_group   
Accessor binding role              none   
Allowed transit encryption modes   user_managed,none
Zone                               us-south-2   
Profile                            dp2   
Size(GB)                           1000   
IOPS                               1000   
Encryption                         provider_managed   
Mount Targets                      ID                          Name      
                                   No mounted targets found.      

Resource group                     ID                                 Name      
                                   6edefe513d934fdd872e78ee6a8e73ef   defaults      

Created                            2025-08-01T21:42:38+00:00   
Replication role                   none   
Replication status                 none   
Replication status reasons         Status code   Status message      
                                   -             -      

Snapshot count                     0   
Snapshot size                      0   
Source snapshot                    -  

创建与 API 的文件共享

您可以通过直接调用 REST API 来创建文件共享和安装目标。

准备工作

设置 API 环境 定义 IAM 令牌、API 端点和 API 版本的变量。 有关指示信息,请参阅设置 API 和 CLI 环境

必须提供 generation 参数并指定 generation=2。 有关详细信息,请参阅 虚拟私有云 API 参考资料 中的生成

要了解有关 API 的更多信息,一个好办法是在 IBM Cloud 控制台中的供应页面上单击获取样本 API 调用。 您可以查看正确的 API 请求序列,并更好地了解操作及其依赖项。

使用应用程序接口创建分区文件共享

发出 POST /shares 请求以创建文件共享。 指定文件共享,名称,IOPS 概要文件和区域的大小。 如果希望创建具有细粒度访问授权的文件共享,请指定 "security_group 为访问模式。 具有安全组访问模式的共享也可配置为支持传输中加密、跨区挂载、快照和备份。 请参阅以下示例。

curl -X POST "$vpc_api_endpoint/v1/shares?version=2024-05-06&generation=2"\
-H "Authorization: $iam_token" \
-d '{
    "access_control_mode": "security-group",
    "allowed_transit_encryption_modes": ["none","user-managed"],
    "size": 4800,
    "iops": 3000,
    "name": "myshare-1",
    "profile": {"name": "dp2"},
    "zone": {"name": "us-south-1"}
}

确保在创建挂载目标时,还指定了一个虚拟网络接口,该接口是虚拟服务器实例所属安全组的成员。

下面的示例显示了创建 4800 GB 文件共享的请求。 它指定访问控制方式 vpc,这使每个安装目标的 VPC 中的所有客户机都能够访问此文件共享。 该选项安全性较低,而且不支持更新的功能。

curl -X POST "$vpc_api_endpoint/v1/shares?version=2023-08-08&generation=2"\
-H "Authorization: $iam_token" \
-d '{
    "size": 4800,
    "iops": 3000,
    "name": "myshare-1",
    "profile": {"name": "dp2"},
    "access_control_mode": "vpc",
    "zone": {"name": "us-south-1"}
  }'

成功回复的示例如下

{
  "access_control_mode": "vpc",
  "created_at": "2023-08-08T22:31:50Z",
  "crn": "crn:[...]",
  "encryption": "provider_managed",
  "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/acd96d70-b8d3-4b56-ad7f-9c1035df93b2",
  "id": "acd96d70-b8d3-4b56-ad7f-9c1035df93b2",
  "initial_owner": {
    "gid": 0,
    "uid": 0
  },
  "iops": 3000,
  "lifecycle_state": "pending",
  "name": "myshare-1",
  "profile": {
    "href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/dp2",
    "name": "dp2",
    "resource_type": "share_profile"
  },
  "replication_role": "none",
  "replication_status": "none",
  "replication_status_reasons": [],
  "resource_group": {
    "crn": "crn:v1:public:resource-controller::a/e2f80b84-bc75-4f53-8737-8193ef1d1a7b::resource-group:e96d1fa9-76f2-4c87-a737-dbab3a947b24",
    "href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/e96d1fa9-76f2-4c87-a737-dbab3a947b24",
    "id": "e96d1fa9-76f2-4c87-a737-dbab3a947b24",
    "name": "Default"
  },
  "resource_type": "share",
  "size": 4800,
  "mount_targets": [],
  "zone": {
    "href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1",
    "name": "us-south-1"
  }
}

使用应用程序接口创建区域文件共享

拥有预览新区域文件共享产品特殊权限的客户可以使用 rfs 配置文件创建具有区域可用性和可调带宽值的文件共享。

下面的示例显示了如何创建 1000GB 带宽为 60 Mbps 的区域文件共享。 此文件共享是使用缺省安全组访问方式和提供者管理的加密创建的。 文件共享将在您登录时选择的区域内创建,无需选择位置。

curl -X POST "$vpc_api_endpoint/v1/shares?version=2025-07-22&generation=2&maturity=beta"\
-H "Authorization: $iam_token" \
-d '{
  "name": "my-regional-share-1",
  "mount_targets": [],
  "profile": {"name": "rfs"},
  "size": 1000,
  "bandwidth": 60,
  "allowed_transit_encryption_modes": ["none","stunnel"],
  "resource_group": {"id": "db8e8d865a83e0aae03f25a492c5b39e"},
  "access_control_mode": "security_group"
}'

有关详细信息,请参阅 Beta VPC API 规范中的创建文件共享方法

使用 API 为文件共享创建安装目标

此请求将创建安装目标或将安装目标添加到现有文件共享。 在此示例中,指定了 vpc 属性,因为文件共享的访问控制方式为 vpc。 无法启用传输中的数据加密。

安装目标和共享的访问控制方式必须匹配。 两者都必须是 vpcsecurity_group。 使用 security_group 访问方式创建安装目标时,请注意共享的 allowed_transit_encryption_modestransit_encryption 值必须反映共享所允许的内容。

curl -X POST "$vpc_api_endpoint/v1/shares/$share_id/mount_targets?version=2023-08-08&generation=2"\
-H "Authorization: Bearer $iam_token"\
-H 'Content-Type: application/json'\
-d '{
    "access_control_mode": "vpc"
    "name": "mount-target-name1",
    "vpc": {"id": "6e01bc24-4a6e-4a0c-a1bd-4caa0c8159e7"},
    "transit_encryption": "none"
  }'

成功回复的示例如下

{
  "access_control_mode": "vpc",
  "created_at": "2023-08-08T23:31:59Z",
  "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/ff859972-8c39-4528-91df-eb9160eae918/mount_targets/9fdf4438-f5b4-4b6f-8bca-602494fd6c31",
  "id": "9fdf4438-f5b4-4b6f-8bca-602494fd6c31",
  "lifecycle_state": "pending",
  "mount_path": "domain.com:/vol_xyz_2891fd0a_63aa_4deb_9ed5_1159e37cb5aa",
  "name": "mount-target-name1",
  "resource_type": "share_target",
  "transit_encryption": "none",
  "vpc": {
    "crn": "crn:[...]",
    "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/e6ff7b61-feb4-4c87-94aa-277d6f93e164",
    "id": "e6ff7b61-feb4-4c87-94aa-277d6f93e164",
    "name": "vpc-name1",
    "resource_type": "vpc"
  }
}

通过指定子网和安全组将安装目标添加到现有文件共享

发出 POST /shares/{share_id}/mount_targets 请求并指定安装目标网络接口的子网和安全组。 与挂载目标相关联的安全组必须允许从要挂载共享的所有服务器 NFS 端口对 TCP 协议进行入站访问。

此示例为现有分区文件共享添加了一个挂载目标,该目标由 ID 标识,并提供了一个子网和安全组来定义网络接口。 已启用传输中加密。

 curl -X POST "$vpc_api_endpoint/v1/shares/r006-201487a2-cf35-4b2a-a4fe-f480803e1e80/mount_targets/?version=2023-07-18&generation=2"\
 -d '{
     "virtual_network_interface": {
        "subnet": {"id": "1a0b3d75-8a62-4c78-9263-f9bcd25a8759"},
        "security_groups": [{"id": "b2599112-7027-480e-ad1b-fd917d2fcb84"}]
     },
     "transit_encryption": "user-managed"
}'

拥有审查区域文件共享产品特殊权限的客户可以使用 Beta VPC API 为其文件共享创建区域挂载目标。 如果要启用传输中加密,请为区域共享指定 "ipsec",为地区共享指定 "stunnel"。

 curl -X POST "$vpc_api_endpoint/v1/shares/r006-ee1f6fc0-6fa3-4821-ad70-f6589e30c566/mount_targets/?version=2025-07-22&generation=2&maturity=beta"\
 -d '{
     "virtual_network_interface": {
        "subnet": {"id": "1a0b3d75-8a62-4c78-9263-f9bcd25a8759"},
        "security_groups": [{"id": "b2599112-7027-480e-ad1b-fd917d2fcb84"}]
     },
     "transit_encryption": "stunnel"
}'

使用 API 创建文件共享和安装目标

以下示例请求将创建一个文件共享,该文件共享具有 VPC 范围的访问方式以及可供指定 VPC 中的每个虚拟服务器实例使用的安装目标。 它还将 用户标记 添加到共享。

对安装目标的访问是 VPC 范围的; VPC 中的所有实例都有权访问此文件共享。 不支持跨区安装和传输中数据加密等新功能。

curl -X POST \
"$vpc_api_endpoint/v1/shares?version=2025-04-08&generation=2\
-H "Authorization: Bearer $iam_token"\
-H 'Content-Type: application/json'\
-d '{
    "access_control_mode": "vpc",
    "size": 4800,
    "iops": 48000,
    "mount_targets": [
      {
        "name": "mount-target-name1",
        "vpc": {"id": "a1fb6c4f-6a63-4d34-8bf6-55fab89e932a"}
      }
    ],
    "name": "share-name1",
    "profile": {"name": "dp2"},
    "user_tags": [
      "env:test",
      "env:prod"
    ],
    "resource_group": {},
    "zone": {"name": "us-south-1"}
  }'

成功回复的示例如下

{
  "access_control_mode": "vpc",
  "allowed_transit_encryption_modes": "none",
  "created_at": "2025-04-08T23:31:59Z",
  "crn": "crn:[...]",
  "encryption": "provider_managed",
  "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/ff859972-8c39-4528-91df-eb9160eae918",
  "id": "ff859972-8c39-4528-91df-eb9160eae918",
  "iops": 48000,
  "lifecycle_state": "stable",
  "name": "share-name1",
  "profile": {
    "href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/dp2",
    "name": "dp2",
    "resource_type": "share_profile"
    },
  "replication_role": "none",
  "replication_status": "none",
  "replication_status_reasons": [],
  "resource_group": {
    "crn": "crn:[...]",
    "href": "https://resource-controller.cloud.ibm.com/v2/resource_groups/6b45d0aa-e0a6-478b-a5d9-bb45b106676d",
    "id": "6b45d0aa-e0a6-478b-a5d9-bb45b106676d",
    "name": "Default"
    },
  "resource_type": "share",
  "size": 4800,
  "mount_targets": [
    {
      "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/ff859972-8c39-4528-91df-eb9160eae918/mount_targets/9fdf4438-f5b4-4b6f-8bca-602494fd6c31",
      "id": "9fdf4438-f5b4-4b6f-8bca-602494fd6c31",
      "name": "mount-target-name1",
      "resource_type": "share_target",
      "vpc": {
        "crn": "crn:[...]",
        "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/e6ff7b61-feb4-4c87-94aa-277d6f93e164",
        "id": "e6ff7b61-feb4-4c87-94aa-277d6f93e164",
        "name": "vpc-name1",
        "resource_type": "vpc"
      }
    }
  ],
  "user_tags": ["env:test","env:prod"],
  "zone": {
    "href": "https://us-south.iaas.cloud.ibm.com/v1/regions/us-south/zones/us-south-1",
    "name": "us-south-1"
  }
}

通过指定子网来创建文件共享和安装目标

文件共享的缺省访问控制方式为 security_group。 它比全 vpc 选项更安全,而且支持更新的功能。 要在创建文件共享的同时使用网络接口创建挂载目标,请发出 "POST /shares 请求并指定子网。 如果不指定 虚拟网络接口,则需要指定 "subnet 属性。

下面的示例创建了一个 虚拟网络接口,并将其附加到挂载目标上,同时保留了一个 IP 地址,并应用了所选安全组的规则。 与挂载目标相关联的安全组必须允许从要挂载共享的所有服务器 NFS 端口对 TCP 协议进行入站访问。

在此示例中,安装目标部分指定子网标识。 创建安装目标时,系统将从该子网中为 虚拟网络接口 选择保留 IP。

curl -X POST "$vpc_api_endpoint/v1/shares?version=2023-08-08&generation=2"\
-H "Authorization: $iam_token"\
-d '{
    "allowed_transit_encryption_modes": ["user-managed"],
    "size": 10,
    "name": "my-share-1",
    "profile": {"name": "dp2"},
     "zone": {"name": "us-south-1"},
     "mount_targets": [{
         "virtual_network_interface": {"subnet": {"id": "4e95744c-7e64-48c9-b5d2-3b6481b1dfde"}},
         "transit_encryption": {"user-managed"}}]
}'

transit_encryption 属性设置为 user_managed 时,将使用实例身份证书启用传输中的加密。 transit_encryption 属性的默认值为 "none,即在传输过程中禁用加密。 但是,如果将“allowed_transit_encryption_modes 指定为”user-managed,则挂载目标必须将“user_managed 作为”transit_encryption 的值。

成功回复的示例如下

 {
    "access_control_mode": "security_group",
    "allowed_transit_encryption_modes": ["user-managed"],
    "created_at": "2023-08-08T12:15:12Z",
    "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/90c4bb62-1724-47bd-8c45-f7d37d7c3508/mount_targets/7e5bdb52-676d-43b2-991f-2053cf6855eb",
    "id": "7e5bdb52-676d-43b2-991f-2053cf6855eb",
    "lifecycle_state": "pending",
    "mount_path": "",
    "name": "myshare-1",
    "primary_ip": {"address": ""},
    "resource_type": "share_target",
    "size": 10,
    "snapshot_count": 0,
    "snapshot_size": 0,
    "subnet": {
        "crn": "crn:[...]",
        "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/4e95744c-7e64-48c9-b5d2-3b6481b1dfde",
        "id": "4e95744c-7e64-48c9-b5d2-3b6481b1dfde",
        "name": "subnet-2",
        "resource_type": "subnet"
    },
    "transit_encryption": "user-managed",
    "virtual_network_interface": {
        "crn": "crn:[...]",
        "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interface/710y-b8aa945c-7eac-4c15-bad6-a56db9d1e9bd",
        "id": "710y-b8aa945c-7eac-4c15-bad6-a56db9d1e9bd",
        "name": "enlace-traverse-oat-console",
        "resource_type": "VirtualNetworkInterface"
    },
    "vpc": {
        "crn": "crn:[...]",
        "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/82fa21ae-a645-4dd5-9136-d48a723bf00e",
        "id": "82fa21ae-a645-4dd5-9136-d48a723bf00e",
        "name": "my-vpc-2",
        "resource_type": "vpc"
    },
    "user_tags": []
}

拥有审查区域文件共享产品特殊权限的客户可以使用 Beta VPC API 为其区域文件共享创建区域挂载目标。 如果要启用传输中加密,请为区域共享指定 "stunnel"。

curl -X POST "$vpc_api_endpoint/v1/shares?version=2025-07-22&generation=2"&maturity=beta"\
-H "Authorization: $iam_token"\
-d '{
    "allowed_transit_encryption_modes": ["stunnel,none"],
    "size": 5000,
    "name": "my-regional-share-1",
    "profile": {"name": "rfs"},
     "mount_targets": [{
         "virtual_network_interface": {"subnet": {"id": "4e95744c-7e64-48c9-b5d2-3b6481b1dfde"}},
         "transit_encryption": {"stunnel"}}]
}'

transit_encryption 属性设置为 stunnel 时,将启用传输中加密,您必须在计算主机上完成几个配置步骤,才能安全挂载文件共享。 在示例中,allowed_transit_encryption_modes 被指定为 stunnel,none,那么挂载目标的 transit_encryption 的值可以是这两个值中的任意一个。

成功回复的示例如下

 {
    "access_control_mode": "security_group",
    "accessor_binding_role": "none",
    "allowed_access_protocols": ["nfs4"],
    "allowed_transit_encryption_modes": ["stunnel"],
    "availability_mode": "regional",
    "access_control_mode": "security_group",
    "bandwidth": 2000,
    "created_at": "2025-07-22T12:15:12Z",
    "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/90c4bb62-1724-47bd-8c45-f7d37d7c3508/mount_targets/7e5bdb52-676d-43b2-991f-2053cf6855eb",
    "id": "7e5bdb52-676d-43b2-991f-2053cf6855eb",
    "lifecycle_state": "pending",
    "mount_path": "",
    "name": "my-regional-share-1",
    "primary_ip": {"address": ""},
    "resource_type": "share_target",
    "size": 5000,
    "snapshot_count": 0,
    "snapshot_size": 0,
    "storage_generation": 2,
    "subnet": {
        "crn": "crn:[...]",
        "href": "https://us-south.iaas.cloud.ibm.com/v1/subnets/4e95744c-7e64-48c9-b5d2-3b6481b1dfde",
        "id": "4e95744c-7e64-48c9-b5d2-3b6481b1dfde",
        "name": "subnet-2",
        "resource_type": "subnet"
    },
    "transit_encryption": "stunnel",
    "virtual_network_interface": {
        "crn": "crn:[...]",
        "href": "https://us-south.iaas.cloud.ibm.com/v1/virtual_network_interface/710y-b8aa945c-7eac-4c15-bad6-a56db9d1e9bd",
        "id": "710y-b8aa945c-7eac-4c15-bad6-a56db9d1e9bd",
        "name": "enlace-traverse-oat-console",
        "resource_type": "VirtualNetworkInterface"
    },
    "vpc": {
        "crn": "crn:[...]",
        "href": "https://us-south.iaas.cloud.ibm.com/v1/vpcs/82fa21ae-a645-4dd5-9136-d48a723bf00e",
        "id": "82fa21ae-a645-4dd5-9136-d48a723bf00e",
        "name": "my-vpc-2",
        "resource_type": "vpc"
    },
    "user_tags": []
}

通过指定子网和安全组来创建文件共享和安装目标

要创建安装目标网络接口,请发出 POST /shares 请求并指定子网和安全组。 与挂载目标相关联的安全组必须允许从要挂载共享的所有服务器 NFS 端口对 TCP 协议进行入站访问。

在下面的示例中,mount_targets 属性指定了子网 ID 和安全组 ID。 当 transit_encryption 属性设置为 user_managed 时,它将通过使用实例身份证书来启用传输中的加密。 缺省值为 none,这将禁用传输中的加密。

curl -X POST "$vpc_api_endpoint/v1/shares?version=2023-08-08&generation=2"\
-H "Authorization: $iam_token" \
-d '{
    "size": 20,
    "iops": 100,
    "name": "myshare-3",
    "profile": {"name": "dp2"},
    "zone": {"name": "us-south-1"},
    "allowed_transit_encryption_modes": ["user-managed"],
    "mount_targets": [{
        "virtual_network_interface": {
            "subnet": {"id": "4e95744c-7e64-48c9-b5d2-3b6481b1dfde"},
            "security_groups": [{"id": "34c09abb-37bf-4ef6-88bb-f63a0ef28915"}]
        },
        "transit_encryption": {"user_managed"}}
      ]
    }'

以下响应显示访问控制方式为 security_group,这是缺省值。

{
    "access_control_mode": "security_group",
    "allowed_transit_encryption_modes": ["user-managed"],
    "created_at": "2023-08-08T12:55:40Z",
    "crn": "crn:[...]",
    "encryption": "provider_managed",
    "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/r006-56f91d4a-2801-470a-b368-176bde64e954",
    "id": "r006-56f91d4a-2801-470a-b368-176bde64e954",
    "initial_owner": {
        "gid": 0,
        "uid": 0
    },
    "iops": 100,
    "lifecycle_state": "pending",
    "name": "myshare-3",
    "mount_targets": [
        {
            "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/r006-56f91d4a-2801-470a-b368-176bde64e954/mount_targets/r006-b8573e2c-60ee-4ecc-9eae-c52f890a8195",
            "id": "r006-b8573e2c-60ee-4ecc-9eae-c52f890a8195",
            "name": "sticky-idealist-spoiled-sloppily",
            "resource_type": "share_target",
            "transit_encryption": {"user_managed"}
        }
    ],
    "profile": {
        "href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/dp2",
        "name": "dp2",
        "resource_type": "share_profile"
    },
    "replication_role": "none",
    "replication_status": "none",
    "replication_status_reasons": [],
    "resource_group": {
        "crn": "crn:[...]",
        "href": "https://resource-controller.cloud.ibm.com/v2/resource_groups//678523bcbe2b4eada913d32640909956",
        "id": "678523bcbe2b4eada913d32640909956",
        "name": "Default"
    },
    "resource_type": "share",
    "size": 20,
    "snapshot_count": 10,
    "snapshot_size": 10,
    "user_tags": [],
    "zone": {
        "href": "https://us-south.cloud.ibm.com/v1/regions/us-south/zones/us-south-1",
        "name": "us-south-1"
    }
}

拥有审查区域文件共享产品特殊权限的客户可以使用 Beta VPC API 创建文件共享。 在下面的示例中,mount_targets 属性指定了子网 ID 和安全组 ID。 当 transit_encryption 属性设置为 ipsec 时,它将通过使用实例身份证书来启用传输中的加密。 此选项仅适用于区域文件共享。 区域文件共享使用 stunnel 进行传输中加密。

curl -X POST "$vpc_api_endpoint/v1/shares?version=2025-07-22&generation=2&maturity=beta"\
-H "Authorization: $iam_token" \
-d '{
    "size": 20,
    "iops": 100,
    "name": "my-share-3",
    "profile": {"name": "dp2"},
    "zone": {"name": "us-south-1"},
    "allowed_transit_encryption_modes": ["ipsec"],
    "mount_targets": [{
        "virtual_network_interface": {
            "subnet": {"id": "4e95744c-7e64-48c9-b5d2-3b6481b1dfde"},
            "security_groups": [{"id": "34c09abb-37bf-4ef6-88bb-f63a0ef28915"}]
        },
        "transit_encryption": {"ipsec"}}
      ]
    }'

以下响应显示访问控制方式为 security_group,这是缺省值。

{
    "access_control_mode": "security_group",
    "accessor_binding_role": "none",
    "allowed_access_protocols": ["nfs4"],
    "allowed_transit_encryption_modes": ["ipsec"],
    "availability_mode": "zonal",
    "created_at": "2025-07-22T12:55:40Z",
    "crn": "crn:[...]",
    "encryption": "provider_managed",
    "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/r006-56f91d4a-2801-470a-b368-176bde64e954",
    "id": "r006-56f91d4a-2801-470a-b368-176bde64e954",
    "initial_owner": {
        "gid": 0,
        "uid": 0
    },
    "iops": 100,
    "lifecycle_state": "pending",
    "name": "myshare-3",
    "mount_targets": [
        {
            "href": "https://us-south.iaas.cloud.ibm.com/v1/shares/r006-56f91d4a-2801-470a-b368-176bde64e954/mount_targets/r006-b8573e2c-60ee-4ecc-9eae-c52f890a8195",
            "id": "r006-b8573e2c-60ee-4ecc-9eae-c52f890a8195",
            "name": "sticky-idealist-spoiled-sloppily",
            "resource_type": "share_target",
            "transit_encryption": {"ipsec"}
        }
    ],
    "profile": {
        "href": "https://us-south.iaas.cloud.ibm.com/v1/share/profiles/dp2",
        "name": "dp2",
        "resource_type": "share_profile"
    },
    "replication_role": "none",
    "replication_status": "none",
    "replication_status_reasons": [],
    "resource_group": {
        "crn": "crn:[...]",
        "href": "https://resource-controller.cloud.ibm.com/v2/resource_groups//678523bcbe2b4eada913d32640909956",
        "id": "678523bcbe2b4eada913d32640909956",
        "name": "Default"
    },
    "resource_type": "share",
    "size": 20,
    "snapshot_count": 10,
    "snapshot_size": 10,
    "storage_generation": 1,
    "user_tags": [],
    "zone": {
        "href": "https://us-south.cloud.ibm.com/v1/regions/us-south/zones/us-south-1",
        "name": "us-south-1"
    }
}

通过指定虚拟网络接口来创建文件共享和安装目标

要执行此操作,您必须已经拥有一个 虚拟网络接口,且该虚拟网络接口不得连接到其他资源。

发出 POST /shares 请求并使用虚拟网络接口创建安装目标。 在挂载目标的 "virtual_network_interface 属性中指定未连接虚拟网络接口的 ID。

curl -X POST "$vpc_api_endpoint/v1/shares?version=2023-08-08&generation=2" \
-H "Authorization: $iam_token" \
-d '{
    "size": 10,
    "name": "my-share-sc-2",
    "profile": {"name": "dp2"},
    "zone": {"name": "us-south-3"},
    "allowed_transit_encryption_modes": ["none"],
    "mount_targets": [{
        "name": "mount-target-1",
        "transit_encryption": {"none"},
        "virtual_network_interface": {"id": "0767-fa41aecb-4f21-423d-8082-630bfba1e1d9"}
      }]
    }'

使用 API 从快照创建文件共享

有关如何从快照创建文件共享的详细信息,请参阅 从文件共享快照恢复数据

使用 API 创建文件共享时添加补充标识

通过该 API,您可以为 initial_owner 属性设置 UIDGID 值,以控制对文件共享的访问。 无论您在何处安装文件共享,根文件夹都会使用该用户标识和组标识所有者。 在 POST /shares 调用中创建共享时设置 UID 和/或 GID

如果从虚拟服务器实例更改补充标识 (UID 或 GID),那么无法确定其是否已更改。 因此,initial_owner 不会在 API 数据库中进行更改,而是仅在文件存储系统中进行更改。

表 1 显示了可以设置的 UID 和 GID 值以及保留的值。

Unix/Linux® supplemental ID values.
标识值 描述
UID
UID 0 保留用于 root 用户。
UID 1-99 保留用于预定义帐户。
UID 100-999 由系统为管理系统帐户和组保留。
UID 1000-10000 由应用程序帐户使用。
UID 10000 + 可用于用户帐户。
GID
GID 0 保留用于 root 用户。
GID 1-99 保留供系统和应用程序使用。
100 + GID 已分配给用户的组。

要在创建共享时设置补充标识,请发出 POST /shares 调用并使用补充标识指定 initial_owner 属性。 请参阅以下示例。

curl -X POST \
"$vpc_api_endpoint/v1/shares?version=2023-08-08&generation=2"\
-H "Authorization: $iam_token" \
-d '{
    "initial_owner": {"gid": 101,"uid": 10001},
    "size": 4800,
    "name": "share-name",
    "profile": {"name": "dp2"},
    "zone": {"name": "us-south-1"}
     .
     .
     .
   }'

使用 Terraform 创建文件共享和安装目标

要使用 Terraform,请下载 Terraform CLI 并配置 IBM Cloud® 提供程序插件。 有关更多信息,请参阅 Terraform 入门

VPC 基础架构服务使用特定区域端点,缺省情况下该端点以 us-south 为目标。 如果 VPC 是在另一个区域中创建的,请确保将 provider.tf 文件中的提供程序块中的相应区域作为目标。

请参阅以下以非缺省 us-south 区域为目标的示例。

provider "ibm" {
   region = "eu-de"
}

使用 Terraform 创建文件共享

要创建文件共享,请使用 ibm_is_share 资源。 以下示例创建具有 200 GB 容量的共享以及 dp2 性能概要文件。

resource "ibm_is_share" "example" {
  allowed_transit_encryption_modes = "none"
  name                             = "my-new-share"
  size                             = "200"
  iops                             = "500"
  profile                          = "dp2"
  zone                             = "us-south-2"
}

创建具有 Terraform 的副本的文件共享

要创建文件共享,请使用 ibm_is_share 资源。 要添加副本,请定义与以下示例类似的副本共享。 它将创建具有 220 GB 容量的共享和 dp2 性能概要文件。 replica_share 参数定义副本共享的名称,复制频率 (在 cron 规范中),性能概要文件以及要在其中创建副本共享的区域。

resource "ibm_is_share" "example-2" {
  allowed_transit_encryption_modes = "none"
  zone                             = "us-south-1"
  size                             = "220"
  name                             = "my-share"
  profile                          = "dp2"
  replica_share {
    name                           = "my-replica"
    replication_cron_spec          = "0 */5 * * *"
    profile                        = "dp2"
    zone                           = "us-south-3"
  }
}

使用 Terraform 从快照创建文件共享

有关如何从快照创建文件共享的详细信息,请参阅 从文件共享快照恢复数据

使用 Terraform 创建安装目标

要为使用安全组提供粒度认证的文件共享创建安装目标,请使用 is_share_mount_target 资源。 以下示例创建具有 security_group 访问控制方式的安装目标。 首先,指定创建挂载目标的共享。 然后,指定安装目标的名称,并通过提供 IP 地址和名称来定义新的虚拟网络接口。 您还必须指定要用于管理对与安装目标关联的文件共享的访问权的安全组。 与挂载目标相关联的安全组必须允许从要挂载共享的所有服务器 NFS 端口对 TCP 协议进行入站访问。 属性 auto_delete = true 表示如果删除安装目标,那么将删除虚拟网络接口。

resource "ibm_is_share_mount_target" "target-with-vni" {
     share    = ibm_is_share.is_share.ID
     name     = <share_target_name>
     virtual_network_interface {
             name = <virtual_network_interface_name>
             primary_ip {
             address = “10.240.64.5”
             auto_delete = true
             name = <reserved_ip_name>
     }
     resource_group = <resource_group_id>
     security_groups = [<security_group_ids>]
     transit_encryption = none
   }
}

您还可以使用 is_share_mount_target 资源为具有 VPC 访问方式的文件共享创建安装目标。 以下示例为由其标识指定的文件共享创建名为 my-share-target 的安装目标。 创建安装目标时,VPC 中的所有虚拟服务器实例都可以使用它来安装共享。

resource "ibm_is_share_mount_target" "target-without-vni" {
     share=ibm_is_share.is_share.ID
     name = <share_target_name>
     vpc = <vpc_id>
}

有关自变量和属性的更多信息,请参阅 ibm_is_share_mount_target

使用安全组访问方式创建与安装目标的文件共享

您无需单独创建文件共享和安装目标。 要与允许在 VPC 中进行基于安全组的认证的安装目标创建文件共享,请使用 ibm_is_share 资源。 将访问控制方式指定为 security_group,并通过为其提供名称,虚拟网络接口的详细信息 (例如,名称,子网或 IP 地址) 来定义安装目标。 此外,指定要用于控制对文件共享的访问权的安全组。 与挂载目标相关联的安全组必须允许从要挂载共享的所有服务器 NFS 端口对 TCP 协议进行入站访问。

resource "ibm_is_share" "share4" {
   zone    = "us-south-2"
   size    = "800"
   name    = "my-share4"
   profile = "dp2"
   allowed_transit_encryption_modes = "ipsec"
   access_control_mode = "security_group"
   mount_target {
       name = "target"
       virtual_network_interface {
       primary_ip {
               address = 10.240.64.5
               auto_delete = true
               name = <reserved_ip_name>
       }
      resource_group = <resource_group_id>
      security_groups = [<security_group_ids>]
      transit_encryption = ipsec
      }
   }
}

有关自变量和属性的更多信息,请参阅 ibm_is_share

使用 VPC 范围的访问方式创建与安装目标的文件共享

要创建具有可供 VPC 中所有虚拟服务器实例访问的安装目标的文件共享,请使用 ibm_is_share 资源。 将访问控制方式指定为 vpc,并通过为其提供名称以及要在其中使用该方式的 VPC 来定义安装目标。

resource "ibm_is_share" "share3" {
    zone    = "us-south-2"
    size    = "700"
    name    = "my-share3"
    profile = "dp2"
    access_control_mode = "vpc"
    mount_target {
          name = "target"
          vpc = <vpc_id>
    }
}

此类型的文件共享不支持跨区域安装和传输中的加密。

区域共享不支持传统的 VPC 访问模式。

后续步骤

安装文件共享。 安装是一个过程,服务器的操作系统通过该过程使存储设备上的文件和目录可供用户通过服务器的文件系统进行访问。 有关更多信息,请参阅以下主题:

管理文件共享和数据。 有关更多信息,请参阅以下主题: