# Configuring NFS Server on Linux
# on Server
NFS Server
| ~$ sudo apt install nfs-kernel-server |
| |
| ~$ sudo mkdir /nfs |
| ~$ sudo chmod a+w /nfs |
| ~$ sudo cat >>/etc/exports <<EOF |
| /nfs 10.10.10.222/24(rw,sync,no_subtree_check) |
| EOF |
| |
| ~$ sudo systemctl enable nfs-kernel-server |
| ~$ sudo ufw allow from 10.10.10.1/24 to any port nfs |
| |
| ~$ showmount -e localhost |
| ~] |
| |
| ~] |
| ~] |
| ~] |
| /nfs *(rw,sync,no_root_squash) |
| EOF |
| |
| ~] |
| ~] |
| ~] |
| ~] |
| ~] |
| ~] |
| |
| ~] |
| Export list for localhost: |
| /nfs * |
| ~]$ sudo dnf -y install nfs-utils |
| |
| ~]$ sudo mkdir /nfs |
| ~]$ chmod a+w /nfs |
| ~]$ cat >>/etc/exports <<EOF |
| /nfs *(fsid=0,rw,sync,no_root_squash,no_subtree_check,crossmnt) |
| EOF |
| |
| ~]$ sudo systemctl enable --now nfs-server |
| ~]$ sudo firewall-cmd --permanent --add-service=nfs |
| ~]$ sudo firewall-cmd --permanent --add-service=rpc-bind |
| ~]$ sudo firewall-cmd --permanent --add-service=mountd |
| ~]$ sudo firewall-cmd --reload |
| |
| ~] |
| Export list for localhost: |
| /nfs * |
| ~] |
| nfs-utils-1.0.6-93.EL4 |
| nfs-utils-lib-1.0.6-10.el4 |
| |
| ~] |
| /nfs *(rw,sync,no_root_squash) |
| |
| ~] |
| ~] |
| Export list for localhost: |
| /nfs (everyone) |
# on Client
NFS Client
| ~]$ showmount -e 192.168.184.148 |
| Export list for 192.168.184.148: |
| /nfs * |
| |
| ~] |
| ~] |
| |
| ~] |
| 192.168.184.148:/nfs nfs4 47G 6.1G 41G 13% /backup |
# showmount -e 192.168.3.58
export list for 192.168.3.58:
/nfs *
# mkdir /exp
# mount 192.168.3.58:/nfs /exp
mount: 1831-008 giving up on:
192.168.3.58:/nfs
vmount: Operation not permitted.
# nfso -a | grep nfs_use_reserved_ports
nfs_use_reserved_ports = 0
# nfso -o nfs_use_reserved_ports=1
Setting nfs_use_reserved_ports to 1
# nfso -a | grep nfs_use_reserved_ports
nfs_use_reserved_ports = 1
# mount -v nfs -o rw,bg,hard,rsize=32768,wsize=32768,vers=3,nointr,timeo=600,proto=tcp 192.168.3.58:/nfs /exp
# df -g
Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/hd4 0.09 0.06 39% 2145 14% /
/dev/hd2 1.94 0.28 86% 30455 31% /usr
/dev/hd9var 0.19 0.15 18% 615 2% /var
/dev/hd3 0.09 0.09 2% 23 1% /tmp
/dev/hd1 0.03 0.03 2% 7 1% /home
/dev/hd11admin 0.12 0.12 1% 5 1% /admin
/proc - - - - - /proc
/dev/hd10opt 0.09 0.01 92% 474 20% /opt
/dev/livedump 0.25 0.25 1% 4 1% /var/adm/ras/livedump
192.168.3.58:/nfs 43.37 30.13 31% 134553 3% /exp
# /etc/exports - NFS server export table
A line for an exported file system has the following structure:
<export> <host1>(<options>)
There should be no space between "host" and "(option)", otherwise there will be permission issues. Like touch: cannot touch ‘1’: Read-only file system