Filestore on [[GCP]] is a Network File System (NFS) or distributed file system which allows you to access files over a virtual network just like a local file system. You might mount a Filestore to a VM on [[Compute Engine]] or [[Kubernetes]] for web content or data intensive applications like [[genomics]] that require file-based data. Filestore is pretty expensive for persistent usage so consider other [[storage and database]] options first.
To mount Filestore to a VM, first set up the VM and Filestore in a project. In the Cloud Engine dashboard, click the SSH for the VM to open the shell and connect via SSH. Use the command below to install `nfs`.
```bash
sudo apt-get -y update &&
sudo apt-get -y install nfs-common
```
Then create a directory `/mnt` and mount the Filestore instance by its IP address and name.
```bash
sudo mkdir -p /mnt
sudo mount 10.24.183.98:/my-filestore /mnt
```
Use the IP address from the Filestore dashboard and the name you initialized it with.
Finally set permissions so the files are read and writable.
```bash
sudo chmod go+rw /mnt
```
To test the mount, create a file, check that it was created, and print the contents.
```bash
echo 'This is a test' > /mnt/testfile
ls /mnt
cat /mnt/testfile
```
