Creating file shares and mount targets
Create file shares and mount targets in the UI, CLI, API, or Terraform.
Before you get started, to create mount targets for file shares, make sure that you created a VPC.
You can create file shares and mount targets either of the following ways:
- Create a file share and mount target together,
- Create a file share and add mount target later.
Creating a file share in the UI
In the IBM Cloud console, you can create a file share with or without a mount target. However, you need to create a mount target when you want to mount the share on a virtual server instance. You can create multiple mount targets for the share if it's to be used by hosts in different VPCs.
Creating a mount target in the UI
You can create several mount targets for an existing file share if the share is to be used by resources in multiple VPCs. You can create one mount target per VPC for the file share. When you create multiple mount targets for the same file share, their encryption in transit value must match.
-
In the IBM Cloud console, click the Navigation Menu icon > VPC Infrastructure > Storage > File shares.
-
Select a file share from the list.
-
On the File shares details page, under Mount targets, click Create.
You must have at least one VPC to create a mount target. If you don't have one, first create a VPC.
-
Depending on the mount target access mode of the share, the Create mount target form looks different.
-
If the share has security group access mode, enter the following information. This action creates and attaches a virtual network interface to your mount target that identifies the file share with a reserved IP address and applies the rules of the selected security group. This mount target supports encryption-in-transit and cross-zone mounting.
Table 4. Values for creating a mount target. Field Value Details Mount target name Specify a mount target name. The name can be up to 63 lowercase alpha-numeric characters and include the hyphen (-), and must begin with a lowercase letter. You can later edit the name if you want. Zone Zone is inherited from the file share (for example, Dallas 2). VPC Select an available VPC. The list includes only those VPCs with a subnet in the selected zone. Subnet Select a subnet from the list. Reserved IP address Required for the mount target. The IP address cannot be changed afterward. However, you can delete the mount target and create another one with a different IP address. Reserving method You can have the file service select an IP address for you. The reserved IP becomes visible after the mount target is created. Or, specify your own IP. Auto-release Releases the IP address when you delete the mount target. Enabled by default. Security groups The security group for the VPC is selected by default, or select from the list. Encryption in transit Disabled by default, click the toggle to enable. For more information about this feature, see Encryption in transit - Securing mount connections between file share and host. -
If the share has VPC as the access mode, provide a name for the mount target and select a VPC from the list. This mount target can be used to mount the file share on any virtual server instance of the selected VPC in the same zone as the file share. Cross-zone mounting is not supported.
-
-
Click Create.
Creating a file share from the CLI
Before you begin
Before you can use the CLI, you must install the IBM Cloud CLI and the VPC CLI plug-in. For more information, see the CLI prerequisites.
-
After you install the VPC CLI plug-in, set the target to generation 2 by running the
ibmcloud is target --gen 2
command. -
Make sure that you created an IBM Cloud VPC.
Gathering information from the CLI
Before you run the ibmcloud is share-create
command, you can gather information that you need for provisioning a share by viewing information about other file shares, mount targets, and file storage profiles.
Details | Listing options | What it provides |
---|---|---|
File shares | ibmcloud is shares |
List all shares in a region. |
File share details | ibmcloud is share SHARE_ID |
Review details of a share. |
File share profiles | ibmcloud is share-profiles |
List all file share profiles in a region. Only dp2 can be used to create file shares. |
Mount targets | ibmcloud is share-mount-targets SHARE_ID |
List all mount targets for a file share. |
Subnets | ibmcloud is subnets |
List all subnets. |
Reserved IP addresses | ibmcloud is subnet-reserved-ips |
List all reserved IP addresses in the subnet. |
Security Groups | ibmcloud is security-groups |
List all security groups. |
Creating a mount target for a file share from the CLI
To create a mount target for the file share, run the share-mount-target-create
command. Before you begin, gather some necessary information.
When you create a mount target, you must specify the file share that it is for. You can use the file share's name or ID. You must specify the VPC, too, either with its ID or name. The VPC must be unique to each mount target. You must also specify the security access group that's going to be used to manage access to the share. The security groups that you associate with a mount target must allow inbound access for the TCP protocol on the NFS port from all virtual server instances on which you want to mount the file share.
Lastly, you must specify values for the options that are needed to create a virtual network interface for the mount target. Use the appropriate CLI commands to list the available subnets, reserved IP addresses in a subnet, security groups to get the information that you need.
The following example creates a mount target with a virtual network interface for a file share that has security group access mode.
$ 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 --vni-sgs my-sg --resource-group-name Default --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-dd497561-c7c9-4dfb-af0a-c84eeee78b61
Name my-cli-share-mount-target-1
VPC ID Name
r006-6e8fb140-5668-45b8-b98a-d5cb0e0bf39b my-vpc
Access control mode security_group
Resource type share_mount_target
Virtual network interface ID Name
r006-13c070d8-d038-49c6-95f5-e8503c5595e3 my-share-vni-1
Lifecycle state pending
Mount path -
Transit Encryption none
The following example creates a mount target for a file share that has VPC access mode.
$ ibmcloud is share-mount-target-create my-vpc-file-share --vpc my-vpc --name my-vpc-mount-target
Mounting target for share r006-b1707390-3825-41eb-a5bb-1161f77f8a58 under account Test Account as user test.user@ibm.com...
ID r006-5ed68506-860e-4dea-a1eb-9634704e3c4d
Name my-vpc-mount-target
VPC ID Name
r006-6e8fb140-5668-45b8-b98a-d5cb0e0bf39b my-vpc
Access control mode vpc
Resource type share_mount_target
Lifecycle state pending
Mount path -
Transit Encryption none
Created 2023-10-18T23:09:43+00:00
For more information about the command options, see ibmcloud is share-mount-target-create
.
You can create several mount targets for an existing file share if the share is to be used by resources in multiple VPCs. You can create one mount target per VPC for the file share. When you create multiple mount targets for the same file share, their encryption in transit value must match.
Creating a file share with the API
You can create file shares and mount targets by directly calling the REST APIs.
Before you begin
Set up your API environment. Define variables for the IAM token, API endpoint, and API version. For instructions, see Setting up your API and CLI environment.
You must provide the generation
parameter and specify generation=2
. For more information, see Generation in the Virtual Private Cloud API reference.
A good way to learn more about the API is to click Get sample API call on the provisioning pages in IBM Cloud console. You can view the correct sequence of API requests and better understand actions and their dependencies.
Creating a mount target for a file share with the API
This request creates or adds a mount target to an existing file share. In this example, the vpc
property is specified because the file share's access control mode is vpc
. Data encryption in transit is not enabled.
Access control modes must match when a mount target is created for an existing share. Both must be either vpc
or security_group
.
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 '{
"name": "mount-target-name1",
"vpc": {"id": "6e01bc24-4a6e-4a0c-a1bd-4caa0c8159e7"},
"transit_encryption": "none"
}'
A successful response looks like the following example.
{
"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"
}
}
When you create a file share with the API, you specify security_group
as the access mode. When you create the mount target, you specify a virtual network interface.
Adding supplemental IDs when you create a file share with the API
With the API, you can set UID
and GID
values for the initial_owner
property to control access to your file shares. Wherever you mount the file share, the root folder uses that user ID and group ID owner.
You set the UID
or GID
, or both when you create a share in a POST /shares
call.
If you change the supplemental IDs (UID or GID) from the virtual server instance, it is not possible to determine that it was changed. As a result, initial_owner
does not change in the API database but changes only in the file
storage system.
Table 1 shows UID and GID values that you can set and values that are reserved.
ID value | Description |
---|---|
UID | |
UID 0 | Reserved for root. |
UID 1–99 | Reserved for predefined accounts. |
UID 100–999 | Reserved by the system for administrative system accounts and groups. |
UID 1000–10000 | Used by applications account. |
UID 10000+ | Available for user accounts. |
GID | |
GID 0 | Reserved for root. |
GID 1–99 | Reserved for the system and application use. |
GID 100+ | Allocated for the user’s group. |
To set supplemental IDs when you create a share, make a POST /shares
call and specify the initial_owner
property with the supplemental IDs. See the following example.
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"}
.
.
.
}'
Creating a file share and mount target with Terraform
To use Terraform, download the Terraform CLI and configure the IBM Cloud® Provider plug-in. For more information, see Getting started with Terraform.
VPC infrastructure services use a regional specific endpoint, which targets to us-south
by default. If your VPC is created in another region, make sure to target the appropriate region in the provider block in the provider.tf
file.
See the following example of targeting a region other than the default us-south
.
provider "ibm" {
region = "eu-de"
}
Next steps
Mount your file shares. Mounting is a process by which a server's operating system makes files and directories on the storage device available for users to access through the server's file system. For more information, see the following topics:
- IBM Cloud File Share Mount Helper utility
- Mounting file shares on Red Hat Linux.
- Mounting file shares in CentOS.
- Mounting file shares on Ubuntu.
- Mounting file shares on z/OS
Manage your file shares and data. For more information, see the following topics: