To manually mount a fileshare to a Linux client VM:
-
Go to the VM instance's page.
-
Locate the Linux VM you want to use as a client, then click SSH to open a terminal on that VM.
-
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
-
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).
-
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
-
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.
-
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
-
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.