18 Mei 2018

Membuat NFS di Ubuntu

 
Beberapa bulan yang lalu, kami memiliki sebuah server storage, menggunakan  NAS4Free, yang kami gunakan untuk menyimpan backup image dari proxmox melalui protokol NFS. Akan tetapi hardisk pada server tersebut mengalami masalah, sehingga server proxmox kami kini tidak memiliki backup.
Kemudian kami juga memiliki sebuah server ubuntu yang memiliki ruang hardisk cukup besar, maka kami berinisiatif untuk menginstall nfs pada server tersebut supaya bisa digunakan untuk membackup image proxmox.
Jika menggunakan NAS4free, maka konfigurasi NFS kita cukup masuk ke menu Protocol, kemudian aktifkan protokol NFS, setelah itu buat directory share, selesai.
Sedangkan pada ubuntu kita harus melakukan sedikit langkah untuk membuatnya.
Berikut ini langkah-langkah membuat NFS Share pada Ubuntu.
Keterangan : 
* IP Server Proxmox (yang nantinya akan melakukan backup image) : 10.10.10.99
* IP Server Ubuntu yang akan dijadikan NFS Share : 192.168.60.4

- Pada Server Ubuntu-

1. Install NFS
sudo apt-get update && sudo apt-get install nfs-kernel-server
2. Buat directory untuk NFS Sharing :
sudo mkdir /var/nfs/backup -p
3. Memberikah Hak Akses pada non-root user
sudo chown nobody:nogroup /var/nfs/backup
4. Konfigurasi pada file /etc/exports Untuk memberikan hak akses ip proxmox

sudo nano /etc/exports
Isikan seperti dibawah (silahkan disesuaikan dengan konfigurasi anda)
/var/nfs/backup       10.10.10.99(rw,sync,no_root_squash,no_subtree_check)
Keterangan :

* rw: This option gives the client computer both read and write access to the volume.
*sync: This option forces NFS to write changes to disk before replying. This results in a more stable and consistent environment since the reply reflects the actual state of the remote volume. However, it also reduces the speed of file operations.
*no_subtree_check: This option prevents subtree checking, which is a process where the host must check whether the file is actually still available in the exported tree for every request. This can cause many problems when a file is renamed while the client has it opened. In almost all cases, it is better to disable subtree checking.
*no_root_squash: By default, NFS translates requests from a root user remotely into a non-privileged user on the server. This was intended as security feature to prevent a root account on the client from using the file system of the host as root. no_root_squash disables this behavior for certain shares.

Langkah terakhir, restart service 
sudo systemctl restart nfs-kernel-server
Kemudian check apakah firewall aktif
sudo ufw status
Apabila firewall aktif, maka tambahkan protokol nfs kedalam firewall
sudo ufw allow from 10.10.10.99 to any port nfs
Setelah selesai, silahkan tambahkan NFS pada proxmox ke IP  192.168.60.4.

Semoga bermanfaat.

Credit to : https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nfs-mount-on-ubuntu-16-04