---
# System prepended metadata

title: Set NFS
tags: [nfs]

---

# Set NFS
[HiPac 3 Release Note and informations](https://hackmd.io/2deAUP8zQ-u1giVioCOdaQ)

Before continue, you need to know your server hostname, server ip, client hostname, client ip
by `hostname` and `ip a` on server and client.

After you know these, add it and  to `/etc/hosts` in this format
`sudo vim /etc/hosts`
```
192.168.1.155 server
192.168.1.156 client
```
This make `server` equal to `192.168.1.155`, this is for saving your time and if your ip changed, only thing need to modify is this.


At server,
```
sudo apt update
sudo apt install nfs-kernel-server -y
```
At client,
```
sudo apt update
sudo apt install nfs-common -y
```

At Server,
```
sudo mkdir -p /shared
sudo chown nobody:nogroup /shared
sudo chmod 777 /shared
```
you can change `/shared` to any dir you liked.

At Server,
`sudo vim /etc/exports`
add this
```
/shared		client(rw,sync,no_subtree_check)
```
Same as `/shared		192.168.1.156(rw,sync,no_subtree_check)`

At Server, Restart nfs with
```
sudo exportfs -a
sudo systemctl restart nfs-kernel-server
sudo systemctl enable nfs-kernel-server
```

At Client,
```
sudo mkdir -p /shared
sudo mount -t nfs server:/shared /shared
```

At Client, to verify mounted 
`df -h`

At Client, auto mount at boot

`sudo vim /etc/fstab`
```
server:/shared /shared nfs defaults 0 0
```


At Server(Optional), allow firewall
```
sudo ufw allow from 192.168.1.0/24 to any port nfs
sudo ufw allow from 192.168.1.0/24 to any port 111
```

To Verify the NFS setup
At Server,
```
cd /shared
touch test
```
At Client,
```
cd /shared
ls
```
If `test` appear, success, if not, deal it with yourself.