创建安装目标时,其传输加密类型必须反映共享的允许传输加密方式。 如果要由不同 VPC 中的资源使用,那么可以为共享创建多个安装目标。 每个 VPC 可为文件共享创建一个挂载目标。
从 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
, Bandwidth
和 Storage 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 -
Beta 当 IBMCLOUD_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
属性设置 UID
和 GID
值,以控制对文件共享的访问。 无论您在何处安装文件共享,根文件夹都会使用该用户标识和组标识所有者。 创建共享时,您可以设置 UID
或 GID
,或两者都设置。
如果从虚拟服务器实例更改补充标识 (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
。 无法启用传输中的数据加密。
安装目标和共享的访问控制方式必须匹配。 两者都必须是 vpc
或 security_group
。 使用 security_group
访问方式创建安装目标时,请注意共享的 allowed_transit_encryption_modes
。 transit_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,您可以为 initial_owner
属性设置 UID
和 GID
值,以控制对文件共享的访问。 无论您在何处安装文件共享,根文件夹都会使用该用户标识和组标识所有者。 在 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"}
.
.
.
}'