synology-nfs-mount-tools/README.md

62 lines
2.4 KiB
Markdown

# synology-nfs-mount-tools
This is a repo that contains tools/documentations to help nfs mounting configuration in Synology
## How to config Synology for NFS
Synology's DSM WebGUI has capability to set NFS configuration to allow Linux to access files on Synology NAS, follow [tutorial: How to access files on Synology NAS within the local network (NFS)](https://www.synology.com/en-us/knowledgebase/DSM/tutorial/File_Sharing/How_to_access_files_on_Synology_NAS_within_the_local_network_NFS)
But the GUI's feature is limited. We need more fine tuning. Following [NFS: Overview and Gotchas](http://www.troubleshooters.com/linux/nfs.htm), we can set Synology properly. (If the URL is broken, we can refer to [NFS: Overview and Gotchas in repo](/source/NFS_Overview/NFS\ Overview\ and\ Gotchas.htm)
### Summary of how to configure NFS server
Configuring an NFS server is just placing a line in `/etc/exports` file. The line's general syntax is:
```
directory_being_shared subnet_allowed_to_access(options)
```
There are 2 kinds of options:
* General options (ignored here)
* User ID Mapping options (need to be mentioned here)
We want to make directories accessible as if the incoming request was from that user or that group, which is done by combining `all_squash` option with `anonuid` and `anongid` options.
e.g.
```
/volume1/homes 192.168.1.85(rw,sync,no_wdelay,crossmnt,all_squash,insecure_locks,sec=sys,anonuid=1025,anongid=100)
```
where:
* `/volume1/homes` is the directory to be shared
* `192.168.1.85` is the ip address of client
* `rw` is Read/Write
* `async` is for fast access. `sync` is for safer access
* `no_wdelay` is "Write disk as soon as possible"
* `anonuid=1025` is uid of "guest"
* `anongid=100` is gid of "guest/user"
### Summary of how to configure client
```
mount -t nfs -o rw 192.168.100.85:/data/altamonte /mnt/test
```
## Current solution
Due to limitation of NFS4.0, idmapping is too hard (mismatch between server and client's uid/gid), and kerberos authentication is too hard to setup. The only solution is NFS+`chown`
1. Setup NFS permission of shared folder on Synology
2. mount volume to client
3. When writing files, remember to chown afterward
For plex server, I need to align LXC's uid and gid with Synology
## Reference
* [NFS: Overview and Gotchas](http://www.troubleshooters.com/linux/nfs.htm)
* [How to setup NFS server and client](https://codeyarns.com/2013/03/17/how-to-setup-nfs-server-and-client/)