NFS (Network File System) is a distributed file system (file server) often used on UNIX-like systems. I personally find Samba easier to work with, but NFS seems to have slightly better performance in many use cases.
You can also access the NFS server from Windows, which is a bit more complicated than Samba. However, please consider that it is almost impossible to access from a smartphone or tablet. We recommend using Samba for such use cases. See Build a Samba server on Arch Linux (https://qiita.com/pttkny/items/90f4c335cb6e94ef46e2).
nfs-utils Install the package.
# pacman -Syu nfs-utils
Make settings to publish the directory. Here we publish data / share / public
to any host at 192.168.0.0/24.
/etc/exports
/data/share 192.168.0.0/24(ro,sync,no_subtree_check,fsid=0)
/data/share/public 192.168.0.0/24(rw,sync,no_subtree_check,nohide)
Here, it is assumed that the uid and gid of the server and the client are the same. If you can't do it in common, you can access it as an anonymous user by adding the all_squash option.
Create the target directory and reflect the settings.
# mkdir -p /data/share/public
# exportfs -arv
Open TCP ports 111,2049,20048. The following is an example of iptables configuration.
/etc/iptables/iptables.rules
-A INPUT -m state --state NEW -m tcp -p tcp --syn -m multiport --dports 111,2049,20048 -j ACCEPT
Start the NFS server.
# systemctl start nfs-server
Also, set NFS to start automatically after a system reboot.
# systemctl enable nfs-server
Mac
Please select one of the following methods.
Shell
You can mount the shared directory on the NFS server as follows:
# mkdir /Volumes/Share
# mount -t nfs -o nolockd,resvport,hard,bg,intr,rw,tcp,nfc 192.168.0.16:/data/share /Volumes/Share
However, this will cause it to be unmounted when the system is rebooted. To allow it to be mounted automatically, add /-/ etc / autofs_nfs
to the end of / etc / auto_master
and create / etc / autofs_nfs
with the following content.
/etc/auto_master
+auto_master # Use directory service
/home auto_home -nobrowse,hidefromfinder
/Network/Servers -fstab
/- -static
/- /etc/autofs_nfs
/etc/autofs_nfs
/System/Volumes/Data/mnt/share -fstype=nfs,nolockd,resvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.0.16/data/share
Execute the following command to reflect it immediately.
# automount -cv
Finder
Click "Move" and "Connect to Server (Command + K)" to display a dialog. Enter an address such as nfs: //192.168.0.16/data/share
.
However, this will cause it to be unmounted when the system is rebooted. To mount it automatically, select the above mount point from "System Preferences", "Users and Groups", "Login Items", and "+".
Recommended Posts