|
| 1 | +--- |
| 2 | +title: NFS file mounting |
| 3 | +description: Learn how to mount NFS file shares onto Coder workspaces. |
| 4 | +--- |
| 5 | + |
| 6 | +This guide will walk you through configuring and mounting an NFS file share to a |
| 7 | +Coder workspace. The NFS file share will be separate from the user's persistent |
| 8 | +volume (represented as `/home/<user>` in the workspace). |
| 9 | + |
| 10 | +## Requirements |
| 11 | + |
| 12 | +To mount an NFS file share, you must use a container-based virtual machine (CVM) |
| 13 | +workspace with a FUSE device attached. You can enable both of these features in |
| 14 | +the admin panel by navigating to **Manage** > **Admin** > **Infrastructure** > |
| 15 | +**Workspace container runtime**. |
| 16 | + |
| 17 | +> Please review |
| 18 | +> [the CVM infrastructure requirements before enabling](https://coder.com/docs/coder/latest/admin/workspace-management/cvms) |
| 19 | +> CVMs and FUSE devices. |
| 20 | +
|
| 21 | +The Coder workspace must have either `nfs-utils` or `nfs-common` installed. |
| 22 | + |
| 23 | +The server must have either `nfs-utils` or `nfs-kernel-server` installed. |
| 24 | + |
| 25 | +Ensure that no firewalls are blocking the client connections. By default, the |
| 26 | +NFS daemon is configured to run on a static port of `2049`. |
| 27 | + |
| 28 | +## Server configuration steps |
| 29 | + |
| 30 | +1. Create an NFS mount on the server for the clients to access: |
| 31 | + |
| 32 | + ```console |
| 33 | + export NFS_MNT_PATH=/mnt/nfs_share |
| 34 | + # Create directory to shaare |
| 35 | + sudo mkdir -p $NFS_MNT_PATH |
| 36 | + # Assign UID & GIDs access |
| 37 | + sudo chown -R uid:gid $NFS_MNT_PATH |
| 38 | + sudo chmod 777 $NFS_MNT_PATH |
| 39 | + ``` |
| 40 | + |
| 41 | +1. Grant access to the clients by updating the `/etc/exports` file, which |
| 42 | + controls the directories shared with remote clients. See |
| 43 | + [Red Hat's docs for more information about the configuration options](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/deployment_guide/s1-nfs-server-config-exports). |
| 44 | + |
| 45 | + ```console |
| 46 | + # Provides read/write access to clients accessing the NFS from any IP address. |
| 47 | + /mnt/nfs_share *(rw,sync,no_subtree_check) |
| 48 | + ``` |
| 49 | + |
| 50 | +1. Export the NFS file share directory. You must do this every time you change |
| 51 | + `/etc/exports`. |
| 52 | + |
| 53 | + ```console |
| 54 | + sudo exportfs -a |
| 55 | + sudo systemctl restart <nfs-package> |
| 56 | + ``` |
| 57 | + |
| 58 | +## Client (Coder workspace) configuration steps |
| 59 | + |
| 60 | +1. Create a directory where the NFS mount will reside: |
| 61 | + |
| 62 | + ```console |
| 63 | + sudo mkdir -p /mnt/nfs_clientshare |
| 64 | + ``` |
| 65 | + |
| 66 | +1. Mount the NFS file share from the server into your workspace: |
| 67 | + |
| 68 | + ```console |
| 69 | + sudo mount <server-IP>:/mnt/nfs_share /mnt/nfs_clientshare |
| 70 | + ``` |
0 commit comments