synology-nfs-mount-tools/README.md

106 lines
4.7 KiB
Markdown

# synology-nfs-mount-tools
This is a repo that contains tools/documentations to help nfs mounting configuration in Synology
## Log
### 2020-07-08
Due to issue from idmapping, NFS customization on Synology is given up. I will directly use Synology's official NAS setting in WebGUI. And set all visitor either as admin or guest
### 2020-07-09
Used one day trying to solve the problem that I cannot write to `/volume1/homes/Jason`, found the problem is from my side. When I created `/mnt/synology_homes_Jason`, I didn't make it `chmod 777`. BAGA!
Anyway, [Applying Default UNIX Permissions](https://www.synology.com/en-us/knowledgebase/DSM/help/FileStation/settings) and [How to manage ACL settings on your Synology NAS](https://www.synology.com/en-global/knowledgebase/DSM/tutorial/File_Sharing/How_to_manage_ACL_settings_on_your_Synology_NAS) are good references
## 0. Knowledge Center: How to config NFS server and client
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)
### 0.1 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"
### 0.2 Summary of how to configure client
```
mount -t nfs -o rw 192.168.100.85:/data/altamonte /mnt/test
```
## 1. Current solution for mapping Synology NFS to Ubuntu (desktop or laptop)
Due to limitation of NFS4.0, idmapping is too hard (mismatch between server and client's uid/gid) to configure at server side, and kerberos authentication is too hard to setup.
This [youtube video](https://www.youtube.com/watch?v=mroM6_koNdw) is the best explanation for me.
The only solution for ubuntu (Desktop or Laptop) is NFS+`chown`
1. Follow Synology official guide + youtube to set NFS permission
2. mount volume to client
3. After writing files, remember to chown afterward
## 2. Current solution for mapping Synology NFS to Proxmox
For plex server:
1. Follow Synology official guide + youtube to set NFS permission
1. add ip address of Proxmox only, no need to add ip address of the LXC within it)
2. Choose squash as "map all user to admin"
2. Mount NFS to Proxmox by go to Datacenter->Storage->Add->NFS, choose different content types.
3. Modify LXC config file after creation of LXC to add mounting point
1. Following [Bind Mount Points](https://pve.proxmox.com/wiki/Linux_Container#_bind_mount_points) to setup bind mount point in config file (in `/etc/pve/lxc`)
e.g. 102.conf
```
arch: amd64
cores: 2
hostname: plexserver
memory: 1024
mp0: /mnt/pve/NAS_media,mp=/mnt/nas_media
net0: name=eth0,bridge=vmbr0,firewall=1,hwaddr=F6:7A:13:86:C5:FD,ip=dhcp,ip6=dhcp,type=veth
ostype: ubuntu
rootfs: local-lvm:vm-102-disk-0,size=8G
swap: 512
unprivileged: 1
```
## 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/)
* [Applying Default UNIX Permissions](https://www.synology.com/en-us/knowledgebase/DSM/help/FileStation/settings)
* [How to manage ACL settings on your Synology NAS](https://www.synology.com/en-global/knowledgebase/DSM/tutorial/File_Sharing/How_to_manage_ACL_settings_on_your_Synology_NAS)
file `video/proxmox_add_nfs.webm` is downloaded from [proxmox 添加 nfs 存储 完美解决 空间不足 虚拟机 备份 容灾 proxmox add nfs](https://www.youtube.com/watch?v=mroM6_koNdw)