# Mount subdirectories of \`rclone serve nfs\`-exported share

**URL:** <https://forum.rclone.org/t/mount-subdirectories-of-rclone-serve-nfs-exported-share/49789>\
**Category:** Feature\
**Created:** [January 29, 2025, 8:45pm UTC](https://forum.rclone.org/t/mount-subdirectories-of-rclone-serve-nfs-exported-share/49789 "2025-01-29T20:45:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gta](https://forum.rclone.org/letter_avatar_proxy/v4/letter/g/c2a13f/32.png) [@gta](https://forum.rclone.org/u/gta)\
**Post date:** [January 29, 2025, 8:45pm UTC](https://forum.rclone.org/t/mount-subdirectories-of-rclone-serve-nfs-exported-share/49789/1 "2025-01-29T20:45:51Z")

</div>

First of all, thanks for making and maintaining Rclone, it's amazing and I have used it a lot (and am still using it daily) in my Homelab and other projects. I haven't seen this asked in the forum or on GitHub yet, so I wanted to ask here first if this is already a feature which I'm failing to set up, or if this could be a possible enhancement.

I was trying to mount a subdirectory of an NFS share, which I exported using `rclone serve nfs`, to a pod in my Kubernetes cluster, and was surprised when the pod mounted the root directory of the exported share instead (which worked perfectly, btw.). After failing to find any obvious errors in my config, I tried to mount the same subdirectory directly on my laptop, which also resulted in the root directory being mounted.

The command I used was:

```auto
sudo mount -t nfs -o port=2049,mountport=2049,tcp <IP>:/my-subdirectory /home/myuser/foo

```

Mounting worked without issues, but instead of `/my-subdirectory`, `/` was mounted.

Is it possible to achieve this already using Rclone, or is this expected? I wasn't able to find or tweak the options of the NFS export, so I'm guessing this is not possible. Maybe the share needs to be exported using the `subtree_check` option, but I'm not 100% sure, as I'm not very well versed in regards to NFS export or mount options, and I couldn't try it for the reasons mentioned above.

There's not a ton of information about `rclone serve nfs` in general, because it's still experimental, but I'm curious to hear if anyone knows more about this!

---

<div class="post-metadata">

**Author:** ![kapitainsky](https://forum.rclone.org/user_avatar/forum.rclone.org/kapitainsky/32/14450_2.png) [@kapitainsky](https://forum.rclone.org/u/kapitainsky)\
**Post date:** [January 30, 2025, 8:36am UTC](https://forum.rclone.org/t/mount-subdirectories-of-rclone-serve-nfs-exported-share/49789/2 "2025-01-30T08:36:27Z")

</div>

Before looking into `rclone serve nfs` inner workings I would test with share served by some standard NFS server. Can you mount sub dir in such case? Or maybe it is NFS general behaviour.

And obviously there is very simple workaround here - run `rclone serve nfs` with directory you plan to mount. You can run multiple instances of `rclone serve` if needed.

---

<div class="post-metadata">

**Author:** ![gta](https://forum.rclone.org/letter_avatar_proxy/v4/letter/g/c2a13f/32.png) [@gta](https://forum.rclone.org/u/gta)\
**Post date:** [January 31, 2025, 10:54pm UTC](https://forum.rclone.org/t/mount-subdirectories-of-rclone-serve-nfs-exported-share/49789/3 "2025-01-31T22:54:38Z")

</div>

Thanks for the reply, @kapitainsky ! Before this feature was available as part of Rclone itself, I used to use a Docker simple container that did something similar. It was based on an alpine image with Rclone and NFS, where I could mount an Rclone config into the container and it would export the mount as an NFS share. This worked perfectly (with subdirectories as well), and I'm still using it currently while experimenting with Rclone's `rclone serve nfs` functionality. I used NFS v4 though, instead of Rclone's NFS v3, but this shouldn't make much of a difference for this use-case.

Thanks for your workaround idea, but unfortunately, I need to be able to mount subdirectories dynamically for this to work well with Kubernetes' [csi-driver-nfs](https://github.com/kubernetes-csi/csi-driver-nfs).

What I'm doing for the time being is mounting the NFS share's root directory in each pod, but then only accessing the specific subdirectory that the given pod needs. However, this is not optimal, because technically, each pod still has access to all data on the entire NFS share.

---

<div class="post-metadata">

**Author:** ![gta](https://forum.rclone.org/letter_avatar_proxy/v4/letter/g/c2a13f/32.png) [@gta](https://forum.rclone.org/u/gta)\
**Post date:** [February 2, 2025, 9:54pm UTC](https://forum.rclone.org/t/mount-subdirectories-of-rclone-serve-nfs-exported-share/49789/4 "2025-02-02T21:54:53Z")

</div>

Short update. I tried this with different CSI providers ([democratic-csi](https://github.com/democratic-csi/democratic-csi) and [csi-driver-nfs](https://github.com/kubernetes-csi/csi-driver-nfs)), as well as mounting it manually on my laptop using the command provided in the docs (but with a subdirectory path instead of `/`), as stated in my previous post. The behavior was the same in all cases, so regardless of which path I put after `<IP>:`, even invalid / nonexistent paths, resulted in the root directory (the one I exported using `rclone serve nfs mymount:`) being mounted.

To add some additional info: The NFS-mount I'm serving with Rclone is a mounted SMB share, which I chained to a crypt mount (SMB -\> Crypt -\> NFS). I wasn't sure whether this setup actually works, but I decided to just try it and it seems to work OK, even though it's slightly unstable when I use it in my pods (I occasionally get stale NFS file handles reported and the mounted volumes become unavailable in the pods). And I was pretty amazed that this entire setup is possible with just one command:

```yaml
command:
  - rclone
args:
  - serve
  - nfs
  - "unas_crypt:"
  - --addr=0.0.0.0:2049
  - --config=/opt/bitnami/rclone/config/rclone.conf
  - --log-level=INFO
  - --cache-dir=/opt/bitnami/rclone/data
  - --dir-cache-time=5m
  - --gid=568
  - --rc
  - --rc-addr=0.0.0.0:5572
  - --rc-user=$(RCLONE_WEB_GUI_USER)
  - --rc-pass=$(RCLONE_WEB_GUI_PASSWORD)
  - --rc-web-fetch-url=https://s3.yuudi.dev/rwa/embed/version.json
  - --rc-web-gui
  - --rc-web-gui-update
  - --rc-web-gui-force-update
  - --rc-web-gui-no-open-browser
  - --tpslimit=128
  - --tpslimit-burst=0
  - --uid=568
  - --umask=000
  - --vfs-cache-max-age=9999h
  - --vfs-cache-max-size=224G
  - --vfs-cache-mode=full
  - --vfs-disk-space-total-size=256G
  - --vfs-fast-fingerprint
  - --vfs-write-back=5m
  - --vfs-read-chunk-size=16M
  - --vfs-read-chunk-size-limit=0
  - --vfs-read-chunk-streams=16

```

I used the exact same command (except with a `dir-cache-time` of 9999) in the past with a Dropbox mount (Dropbox -\> Crypt -\> NFS), and if I recall correctly, I believe this worked fine when I mounted subdirectories using NFS (but unfortunately, I'm not 100% sure if that was actually the case).

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [April 3, 2025, 9:55pm UTC](https://forum.rclone.org/t/mount-subdirectories-of-rclone-serve-nfs-exported-share/49789/5 "2025-04-03T21:55:39Z")

</div>

Closed on April 3, 2025, 9:55pm UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [May 19, 2026, 9:56am UTC](https://forum.rclone.org/t/mount-subdirectories-of-rclone-serve-nfs-exported-share/49789/6 "2026-05-19T09:56:22Z")

</div>

@gta I have fixed this problem - see here

> <https://github.com/rclone/rclone/issues/9442#issuecomment-4480178207>
>
> \#### The associated forum post URL from \`https://forum.rclone.org\`
> 
> https://foru…m.rclone.org/t/mount-subdirectories-of-rclone-serve-nfs-exported-share/49789
> 
> \#### What is your current rclone version (output from \`rclone version\`)?
> 
> \`\`\`
> rclone v1.74.1
> \- os/version: alpine 3.23.4 (64 bit)
> \- os/kernel: 6.17.0-29-generic (x86\_64)
> \- os/type: linux
> \- os/arch: amd64
> \- go/version: go1.26.3
> \- go/linking: static
> \- go/tags: none
> \`\`\`
> 
> \#### What problem are you are trying to solve?
> Hi! I just migrated to this and serving google drive over NFS to replace my local NAS.
> \`\`\`
> gm:
> image: rclone/rclone:latest
> command:
> - serve
> - nfs
> - gdrive:/nfs
> - --addr
> - 0.0.0.0:2049
> - --vfs-cache-mode=full
> environment:
> - RCLONE\_CONFIG=/config/rclone.conf
> volumes:
> - /etc/rclone/rclone.conf:/config/rclone.conf
> - /dev/fuse:/dev/fuse
> ports:
> - 2049:2049
> deploy:
> restart\_policy:
> condition: any
> placement:
> constraints:
> - node.labels.server\_a == true
> \`\`\`
> this is serving the Google Driver over NFS and from what I can tell it seems pretty fast too. Not sure if it will cover all my use cases yet as I can't get it to mount the subpath on the client correctly.
> 
> Lets say I mount this nfs share like this on the client:
> \`\`\`
> sudo mount -t nfs -o port=2049,mountport=2049,tcp server\_a.local:/dir\_a/dir\_b/dir\_c/ /mnt/nfs/
> \`\`\`
> 
> \`/mnt/nfs\` always points to \`/nfs\` directory from Google Drive above from the section \`gdrive:/nfs\`. Basically I can't get it to mount the subpath and I am not sure what I am missing here as it works with my NAS (which is NFSv3).
> 
> \[This\](https://forum.rclone.org/t/mount-subdirectories-of-rclone-serve-nfs-exported-share/49789) person reported the exact same issue, I believe. I am hoping someone here can provide some guidance towards a resolution. Otherwise, I have to go change all my paths. :sad-cat:
> 
> 
> \#### How do you think rclone should be changed to solve that?
> 
> \`rclone serve nfs\` should allow for subdirectories to be mounted by NFS clients.
> 
> 
> 
> \#### How to use GitHub
> 
> \* Please use the 👍 \[reaction\](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to show that you are affected by the same issue.
> \* Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
> \* Subscribe to receive notifications on status change and new comments.

Any testing gratefully received. Replies to the github issue please.
