How to mount a Cloud Filestore fileshare on a Compute Engine virtual machine (VM)?

0 votes
What's the procedure to mount a Cloud Filestore Fileshare on a Linux VM instance on Compute Engine?
Oct 23 in GCP by Karan
• 6,670 points
83 views

1 answer to this question.

0 votes

To manually mount a fileshare to a Linux client VM:

  1. Go to the VM instance's page.

  2. Locate the Linux VM you want to use as a client, then click SSH to open a terminal on that VM.

  3. Install NFS by running the following commands:

    Use the following commands to install NFS on Debian or Ubuntu.

    sudo apt-get -y update
    sudo apt-get install nfs-common
  4. Make a local directory to map to the Cloud Filestore fileshare by running the following command:

    sudo mkdir -p [MOUNT_POINT_DIRECTORY]

    where [MOUNT_POINT_DIRECTORY] is the directory to create (for example /mnt/filedir).

  5. Mount the fileshare from the Cloud Filestore instance by running the mount command. You can use any NFS mount options. For the best performance, we recommend using the default NFS mount options, especially using a hard mount and having the rsize and wsize options set to 1 MB.

    Run the mount command, replacing [VALUES_IN_BRACKETS] with the appropriate values:

    sudo mount [IP_ADDRESS]:/[FILESHARE]/[FILESHARE_SUB_DIR] [MOUNT_POINT_DIRECTORY]

    where:

    • [IP_ADDRESS] is the IP address for the Cloud Filestore instance.

    • [FILESHARE] is the name of the fileshare on the instance.

    • [FILESHARE_SUB_DIR] is the path of the subdirectory in the fileshare to mount. To mount the entire fileshare, leave this blank.

    • [MOUNT_POINT_DIRECTORY] is the path where you want to map the Cloud Filestore fileshare to.

    You can get the IP address and fileshare name of an instance from any of following sources:

    • The Cloud Filestore instances page.

    • The IP_ADDRESS field in the results from the instances list command.

    • The ipaddresses section in the results from the instances describe command.

    For example, given a Cloud Filestore instance with an IP address 10.0.1.2 and a fileshare named share1, the following command mounts the fileshare to the local mount point directory /mnt/render:

    sudo mount 10.0.1.2:/share1 /mnt/render
  6. Optionally, run chmod to set permissions on the mount directory so that it is writable by other than the root user. Run the following command to set directory permissions, replacing [VALUES_IN_BRACKETS] with the appropriate values:

    sudo chmod [PERMISSIONS] [MOUNT_POINT_DIRECTORY]

    where:

    • [PERMISSIONS] is the set of permissions to grant. For example, chmod go+rw makes the directory readable and writeable by users in the group that owns the directory and all other users. For more information about setting permissions, see Configuring access on a fileshare.

    • [MOUNT_POINT_DIRECTORY] is the path to the directory where the Cloud Filestore fileshare is mounted.

  7. Optional: Confirm that the Cloud Filestore fileshare is mounted by running the following command:

    df -h --type=nfs

    The output should contain an entry similar to the following:

     Filesystem        Size    Used  Avail  Use%  Mounted on
     10.0.1.2:/share1  1018G   76M   966G   1%    /mnt/render
     10.0.2.2:/vol3    1018G   76M   966G   1%    /mnt/filestore3
  8. If the applications you plan to use with the mounted Cloud Filestore fileshare require NFS file locking, and this client VM instance is using something other than the default VPC network with unchanged settings, you might need to set two ports on the instance in order to make firewall configuration easier. For more information on determining if you need to configure a firewall rule for the VPC network, see Configuring Firewall Rules. For more information on setting ports, seeSetting NFS Ports.

answered Oct 23 by Sirajul
• 40,990 points

Related Questions In GCP

+1 vote
2 answers

How to open a port on google compute engine

You need to set the firewall rule ...READ MORE

answered Jul 9 in GCP by K sagar
207 views
0 votes
1 answer
0 votes
1 answer

Create a Windows VM instance using Google Compute Engine (GCE).

To create a Windows virtual machine instance ...READ MORE

answered Sep 20 in GCP by Sirajul
• 40,990 points
116 views
0 votes
1 answer

Creating a SQL Server instance using Google Compute engine.

Google Compute Engine provides public images preconfigured with ...READ MORE

answered Sep 23 in GCP by Sirajul
• 40,990 points
65 views