This quickstart shows you how to perform basic operations in Cloud Filestore
gcloud command-line tool from a local terminal window.
In the quickstart, you will:
- Create a Cloud Filestore instance.
- Mount the fileshare from that instance on a client VM instance.
- Create a file on the mounted fileshare.
- Delete the Cloud Filestore instance.
Before you begin
Select or create a GCP project.
Make sure that billing is enabled for your project.
If you haven't already, enable the
gcloudcommand-line tool by installing the Cloud SDK on your computer.
If you already have the Cloud SDK installed, run the following command to update it:
gcloud components update
Create a Compute Engine VM instance to be the client
- Go to the Compute Engine instances page
- Click Create Instance.
- Set Name to nfs-client.
- Set Zone to us-central1-c.
- In the Boot disk section, click Change to begin configuring your boot disk.
- In the OS images tab, choose a Debian or Ubuntu image.
- Click Select.
- In the Firewall section, select Allow HTTP traffic.
- Click Create to create the instance.
Create a Cloud Filestore instance
Create an instance named
nfs-serverby running the following command in a local terminal window:
gcloud filestore instances create nfs-server \ --project=[PROJECT_ID] \ --zone=us-central1-c \ --tier=STANDARD \ --file-share=name="vol1",capacity=1TB \ --network=name="default",reserved-ip-range="10.0.0.0/29"
[PROJECT_ID]is the ID of the GCP project in which to create the instance.
Get information about the instance you just created by running the following command:
gcloud filestore instances describe nfs-server --project=[PROJECT_ID] --zone=us-central1-c
[PROJECT_ID]is the ID of the GCP project in which you created the instance.
Note the IP address in the
ipaddressessection in the response. This is the IP address for the Cloud Filestore instance, which you use to mount the Cloud Filestore fileshare on the client.
The response to the
instances describecommand is similar to the following:
createTime: '2017-11-06T16:49:36.852873Z' name: projects/yourproject/locations/us-central1-c/instances/nfs-server networks: - ipaddresses: - 10.0.0.2 network: default reservedIpRange: 10.0.0.0/29 state: READY tier: STANDARD fileshares: - capacityGb: '1024' name: vol1
When the command completes, leave the terminal window open, as you will use it when you delete the Cloud Filestore instance.
Mount the Cloud Filestore fileshare on the client
- Go to the VM instances page
- In the list of VM instances, click the SSH button for nfs-client to open a terminal window connected to that instance.
Install NFS by running the following commands:
sudo apt-get -y update sudo apt-get -y install nfs-common
Make a mount directory for the Cloud Filestore fileshare by running the following command:
sudo mkdir /mnt/test
Mount the fileshare by running the
mountcommand and specifying the Cloud Filestore instance IP address and fileshare name:
sudo mount 10.0.0.2:/vol1 /mnt/test
Make the fileshare accessible by changing the permissions:
sudo chmod go+rw /mnt/test
Create a file on the fileshare
In the terminal window that is connected to the nfs-client instance, create a file named
testfileby running the following command:
echo 'This is a test' > /mnt/test/testfile
Confirm the file was created by running the following command:
And verifying that
testfileis in the directory contents returned.
To avoid incurring charges to your GCP account for the resources used in this quickstart:
Delete the Cloud Filestore instance by running the following command in your local terminal window:
gcloud filestore instances delete nfs-server --project=[PROJECT_ID] --zone=us-central1-c
[PROJECT_ID]is the ID of the GCP project in which you created the Cloud Filestore instance.
- Go to the VM instances page
- Click the name of the nfs-client instance.
- At the top of the instance's details page, click Delete.
- Follow the instructions at Shutting down projects to delete the GCP project you created.
- Read the Cloud Filestore Overview to learn more about the basics of Cloud Filestore.
- Set up a Cloud Filestore instance on your own by following the instructions at Creating Instances.
- Read the Access Control to learn how to control access to Cloud Filestore operations as well as the resources on an instance.