---
title: "Mount a file system"
description: "The mount command and its options, mounting at boot, allowed sources and firewall rules."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Mount a file system

Clients mount over NFS 4.1, from inside the file system's VPC. Mount by the mount target's
`hostname`, or by its `ipv4Address`. The path is the file system's ID (`/fsy_…`), or an
[access point](/files/access-points)'s (`/fap_…`).

## The mount command

The instance needs an NFS client. On an image without one, install `nfs-common` (Ubuntu, Debian:
`sudo apt-get install -y nfs-common`) or `nfs-utils` (Rocky Linux: `sudo dnf install -y nfs-utils`).

```sh
sudo mount -t nfs4 -o nfsvers=4.1,xprtsec=tls,hard,noresvport,rsize=1048576,wsize=1048576,timeo=600,retrans=2 \
  <hostname>:/<fsy or fap> /mnt/<name>
```

Without TLS, drop `xprtsec=tls`; you can then mount by the address instead of the name:

```sh
sudo mount -t nfs4 -o nfsvers=4.1,hard,noresvport,rsize=1048576,wsize=1048576,timeo=600,retrans=2 \
  <ipv4Address>:/<fsy or fap> /mnt/<name>
```

A file system with `requireTls` accepts only the first. TLS needs a few things on the client first:
see [Encrypt with TLS](/files/tls).

| Option | Why |
| --- | --- |
| `nfsvers=4.1` | Files serves NFS 4.1 |
| `xprtsec=tls` | Encrypts the connection with TLS |
| `hard` | If the file system is briefly unreachable, reads and writes wait and then carry on, instead of failing |
| `noresvport` | Reconnects from a new source port, so a reconnect isn't held up |
| `rsize=1048576,wsize=1048576` | Reads and writes in 1 MiB requests |
| `timeo=600,retrans=2` | Waits 60 seconds before retrying a request, twice before logging that the server isn't responding |

Never use `soft`: it turns a short wait into an I/O error in your application. `nconnect=<n>` (up to
16 connections) is fine.

## Mount at boot

Add a line to `/etc/fstab`. `_netdev` waits for the network:

```txt title="/etc/fstab"
dfc6fl64neocrciu5ogrl4kccq.fs.us-west-1.ezghcompute.com:/fsy_4k2m9x0a7qpe /mnt/shared nfs4 nfsvers=4.1,xprtsec=tls,hard,noresvport,rsize=1048576,wsize=1048576,timeo=600,retrans=2,_netdev 0 0
```

```sh
sudo mkdir -p /mnt/shared
sudo mount /mnt/shared
```

In [user data](/compute/user-data-and-metadata#user-data), cloud-init can do the same at first boot:

```yaml title="user-data.yaml"
#cloud-config
packages:
  - nfs-common
runcmd:
  - mkdir -p /mnt/shared
  - echo "dfc6fl64neocrciu5ogrl4kccq.fs.us-west-1.ezghcompute.com:/fsy_4k2m9x0a7qpe /mnt/shared nfs4 nfsvers=4.1,xprtsec=tls,hard,noresvport,rsize=1048576,wsize=1048576,timeo=600,retrans=2,_netdev 0 0" >> /etc/fstab
  - mount /mnt/shared
```

This mounts with TLS, which works as it is on the [optimized images that support it](/files/tls#optimized-images).
On other images, [set up TLS](/files/tls#set-up-a-client) in the same user data first, or drop
`xprtsec=tls`.

The `hostname` resolves in public DNS. An instance that can't reach the internet can't resolve it:
mount by address, or, for TLS, [add the name to `/etc/hosts`](/files/tls#instances-without-internet-access).

## Allowed sources

A mount target's `allowedSourceCidrs` are the IPv4 CIDRs that may mount through it, 1 to 50 of them.
Left out at create, they're the VPC's ranges. Change them with
[UpdateMountTarget](/files-api/UpdateMountTarget/); the list replaces the previous one:

```sh
curl -X PATCH -H "Authorization: Bearer $EZGH_API_KEY" -H "Content-Type: application/json" \
  -d '{"allowedSourceCidrs": ["10.0.1.0/24", "10.0.2.0/24"]}' \
  "https://files-api.ezghcloud.com/v1/organizations/$ORG_ID/projects/$PROJECT_ID/mount-targets/fmt_7hq2m0x9ka3c"
```

## Firewall rules

Your instances' [firewalls](/compute/firewalls) must allow outbound TCP to port 2049 of the mount
target's address. A firewall that allows all outbound traffic, as a new one does, needs nothing
more. No inbound rule is needed. A rule can name the mount target as its peer, `{ "mountTarget": "fmt_…" }`, instead of
its address.

## Mount targets

| Field | Meaning |
| --- | --- |
| `fileSystem` | Its file system (`fsy_…`). Fixed |
| `subnet` | The subnet its address is in (`sbn_…`), in the file system's VPC. Fixed |
| `ipv4Address`, `hostname` | Its address and DNS name; `null` until it's `available`. Fixed |
| `allowedSourceCidrs` | Who may mount through it |

A file system has at most one mount target per subnet; another is `409 mount_target_exists`. A subnet
in another VPC is `409 vpc_mismatch`. In a subnet with no free address, the create answers `202`, its
operation fails with `subnet_has_no_room`, and the mount target ends `failed`: delete it, and create
one in a subnet with room.

Deleting a mount target ([DeleteMountTarget](/files-api/DeleteMountTarget/)) frees its address.
The file system and its files stay; clients that mounted through it lose access until they mount
through another one.

Source: https://docs.ezghcloud.com/files/mount/index.mdx
