How-To Config NFS Server in ClearLinux OS
Just bought a used Dell R720XD with dual Intel Xeon E5-4650 and 64GB RAM for my HomeLab and install Proxmox as PVE with ZFS native for OS root file system and storage (2 x 4TB WD Red + SSD as ZFS cache, log). Detail explain how to config and setup, I am going to write in another post.
As ClearLinux VM is the main machine for my development, I need to use PC (running Hackintosh Catalina) to able to modify in VSCode and see the build result in filesystem, thus I need to setup NFS server in ClearLinux OS to share home folder /home/bacnh to NFS client.
NFS Server Configuration
I am running latest ClearLinux OS version 32700 at time of writing with local IP: 192.168.11.20
Distribution: Clear Linux OS Installed version: 32700 Version URL: https://cdn.download.clearlinux.org/update Content URL: https://cdn.download.clearlinux.org/update```
Install nfs-utils bundle which included rpcbind and nfs-utils package.
sudo swupd bundle-add nfs-utils
Enable and start rpcbind, nfs-server service, however nfs-server may be failed to start as missing /etc/exports configuration.
sudo systemctl enable rpcbind sudo systemctl enable nfs-server sudo systemctl start rpcbind sudo systemctl start nfs-server
Configure NFS Share
Edit the configuration /etc/exports:
cat /etc/exports /home/bacnh 192.168.11.0/24(rw,all_squash,no_subtree_check,anonuid=1000,anongid=1000)
There are few important notes here:
- 192.168.11.0/24 – as my subnet is 192.168.11.x, this will allow only client at local can access to NFS share. Mainly used for my MBP and my PC. You can increase security by indicating sepcific your machine IP, so other can't access into your NFS share.
- rw - able to read/write the file system
- all_squash,no_subtree_check,anonuid=1000,anongid=1000 -->uid, gid of the home account in the mentioned NFS share. In my case, uid=1000, gid=1000.
Then you must update to current NFS server running and start nfs-server.
sudo exportfs -arv exporting 192.168.11.0/24:/home/bacnh sudo systemctl start nfs-server
By default nfsv4 server is running inside ClearLinux OS at port 2049. If you are using Firewall, you need to open port 2049.
rpcinfo -p | grep nfs 100003 3 tcp 2049 nfs 100003 4 tcp 2049 nfs
As NFS client is build in MacOS, you can check with showmount command:
showmount -e 192.168.11.20 Export list for 192.168.11.20: /home/bacnh 192.168.11.0/24
NFS Client Configuration
As I usually remote directly to my router which is running OpenWrt to do some testing.
First, install needed NFS kernel modules:
opkg update opkg install nfs-utils kmod-fs-nfs kmod-fs-nfs-v4 kmod-fs-nfs-v3
Then mount the NFS share to /mnt/bacnh
mkdir /mnt/bacnh mount -t nfs4 192.168.11.20:/home/bacnh /mnt/bacnh
Then happy using NFS share.
MacOS Catalina - NFS Client
Just to mount the nfs share into home_bacnh folder. Option resvport is needed, otherwise you will get Operation not permitted error.
cd ~/home_bacnh sudo mount -t nfs -o resvport,rw 192.168.11.20:/home/bacnh home_bacnh
Now I can open bacnh NFS share folder inside home folder and starting use VSCode to modify my HomeLab configuration.
By using mount command, I can access my NFS share from any client inside my local network.