# Mounting EFS/NFS to home without root privileges

**URL:** <https://discourse.jupyter.org/t/mounting-efs-nfs-to-home-without-root-privileges/9837>\
**Category:** JupyterHub\
**Created:** [July 1, 2021, 11:21pm UTC](https://discourse.jupyter.org/t/mounting-efs-nfs-to-home-without-root-privileges/9837 "2021-07-01T23:21:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![droctothorpe](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/droctothorpe/32/2603_2.png) [@droctothorpe](https://discourse.jupyter.org/u/droctothorpe)\
**Post date:** [July 1, 2021, 11:21pm UTC](https://discourse.jupyter.org/t/mounting-efs-nfs-to-home-without-root-privileges/9837/1 "2021-07-01T23:21:01Z")

</div>

I filed an issue in the docker-stacks repo, but I’m posting as here as well in case this belongs under support. It does seem to defy categorization to some extent.

Correct me if I’m wrong, but it looks like the [start.sh](https://github.com/jupyter/docker-stacks/blob/73546b703b79a07c44b0f173dbc1602e586d015d/base-notebook/start.sh#L67) script requires root privileges to mount NFS.

I understand that it subsequently deescalates, however, we’re using JupyterHub to provision notebooks on K8s and we want to provide a custom image field in the options form, but there’s no way for us to guarantee deescalation in that context, which is a show-stopper.

**Is it possible to mount an EFS volume to the home directory without running the container as root?** Has anyone successfully implemented a workaround for this configuration expectation?

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [July 2, 2021, 10:24am UTC](https://discourse.jupyter.org/t/mounting-efs-nfs-to-home-without-root-privileges/9837/2 "2021-07-02T10:24:58Z")

</div>

Strictly speaking the mount is handled by the container platform (Docker, Kubernetes), not the container itself.

According to  
[https://docs.aws.amazon.com/efs/latest/ug/accessing-fs-nfs-permissions.html](https://docs.aws.amazon.com/efs/latest/ug/accessing-fs-nfs-permissions.html)  
the default EFS owner is `root` so either it needs to be chowned at run-time which obviously requires admin permissions inside the container, or you set the permissions before it’s mounted.

The above link suggests it might be possible to automate. If you manage to figure it out please share the solution!

---

<div class="post-metadata">

**Author:** ![droctothorpe](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/droctothorpe/32/2603_2.png) [@droctothorpe](https://discourse.jupyter.org/u/droctothorpe)\
**Post date:** [July 2, 2021, 10:49am UTC](https://discourse.jupyter.org/t/mounting-efs-nfs-to-home-without-root-privileges/9837/3 "2021-07-02T10:49:48Z")

</div>

Thanks, Manics! Maybe this can simply be handled at the PV / PVC level. I’ll do some experimentation and submit a PR if I find a solution.

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [July 2, 2021, 4:26pm UTC](https://discourse.jupyter.org/t/mounting-efs-nfs-to-home-without-root-privileges/9837/4 "2021-07-02T16:26:03Z")

</div>

It sounds like EFS now has support for dynamically provisioning Kubernetes volumes:

> **[Introducing Amazon EFS CSI dynamic provisioning | Amazon Web Services](https://aws.amazon.com/blogs/containers/introducing-efs-csi-dynamic-provisioning/)**
>
> As companies move more of their workloads to Kubernetes, they are increasingly deploying applications that need a way to share or persist data or state outside the container. Kubernetes addresses this need by exposing block and file storage systems...

This may make things easier!

---

<div class="post-metadata">

**Author:** ![droctothorpe](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/droctothorpe/32/2603_2.png) [@droctothorpe](https://discourse.jupyter.org/u/droctothorpe)\
**Post date:** [July 2, 2021, 4:59pm UTC](https://discourse.jupyter.org/t/mounting-efs-nfs-to-home-without-root-privileges/9837/5 "2021-07-02T16:59:15Z")

</div>

We messed around with that and found it cumbersome and high maintenance, then switched to [GitHub - kubernetes-sigs/nfs-subdir-external-provisioner: Dynamic sub-dir volume provisioner on a remote NFS server.](https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner). Neither solution provides the ability to mount as non-root though. Both have open issues complaining about precisely this. Looking into an Access Point approach that I have high hopes for. If it works, I’ll submit a PR. Worst case scenario, there’s always an initContainer or the pre\_spawn\_hook, but both implementations seem kind of janky to me.

---

<div class="post-metadata">

**Author:** ![droctothorpe](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/droctothorpe/32/2603_2.png) [@droctothorpe](https://discourse.jupyter.org/u/droctothorpe)\
**Post date:** [January 10, 2022, 7:08pm UTC](https://discourse.jupyter.org/t/mounting-efs-nfs-to-home-without-root-privileges/9837/6 "2022-01-10T19:08:47Z")

</div>

Heads up @manics, I just submitted a PR to z2jh to include documentation that steps through how to use [aws-efs-csi-driver](https://github.com/kubernetes-sigs/aws-efs-csi-driver) along with an EFS Access Point to mount the EFS to the home directory as non-root.

Here’s the link: [Add non-root EFS documentation by droctothorpe · Pull Request #2538 · jupyterhub/zero-to-jupyterhub-k8s · GitHub](https://github.com/jupyterhub/zero-to-jupyterhub-k8s/pull/2538).

---

<div class="post-metadata">

**Author:** ![rgtaylor](https://avatars.discourse-cdn.com/v4/letter/r/a6a055/32.png) [@rgtaylor](https://discourse.jupyter.org/u/rgtaylor)\
**Post date:** [May 6, 2025, 4:43pm UTC](https://discourse.jupyter.org/t/mounting-efs-nfs-to-home-without-root-privileges/9837/7 "2025-05-06T16:43:34Z")

</div>

We were able run non root pods running with NFS using the csi-driver-nfs and also nfs-subdir-external-provisioner by adding singleuser.extraPodConfig to the helm values. In both cases I think the default fsGid settings are ignored as a result of the extraPodConfig settings that we are using to enforce non-root pods so we need to add fsGroup manually to the securityContext.

```auto
  singleuser:
  ¦ extraPodConfig: # Extra settings for spawed pods for Restricted
  ¦ ¦ securityContext:
  ¦ ¦ ¦ runAsUser: 1000
  ¦ ¦ ¦ runAsGroup: 100 # group 1000 not defined on quay.io images
  ¦ ¦ ¦ fsGroup: 100 # this is the fix for getting csi-driver-nfs to mount group=users
  ¦ ¦ ¦ seccompProfile:
  ¦ ¦ ¦ ¦ type: RuntimeDefault
  ¦ ¦ ¦ runAsNonRoot: true
  ¦ ¦ ¦ allowPrivilegeEscalation: false

```
