How To Create A Proxmox Ubuntu NFS Server
An Ubuntu NFS Server or Network File Share will allow you to share files and directories with other network clients. It’s a little like a fuse mount where you would mount a directory to share documents but much more secure. A great advantage of this is sharing files like OS templates in a Proxmox cluster. Unlike SolusVM where each template needs to be saved on the host, consuming valuable resources, Proxmox has the ability to connect each host to an NFS Server to use a centralized system of templates. So, you can easily create VPS servers.
We’ve created a central Ubuntu 20 VM and are going to use this as a central source for our host’s to connect to and download templates from. Because Proxmox comes ready built with an NFS client this guide will just focus on creating the NFS server and allowing access to the hosts.
Install Proxmox Ubuntu NFS Server
Use apt to download and install the NFS server
apt install nfs-kernel-server
Next, we need to decide on a name for our shared directory. This is known as an export directory and this is the directory each host will connect to. We’re going to use cluster-templates.
mkdir -p /mnt/cluster-templates
Because we need all host’s to have access to the templates, we enasure root is assigned to as the user and group to this folder only. We can use chown and chmod to accomplish this.
chown -R root:root /mnt/cluster-templates chmod 777 /mnt/cluster-templates
Allow Access To NFS Server
Because by default all connections to your Proxmox Ubuntu NFS server will be blocked. To allow hosts to connect to our server we need to whitelist the IP they are using. We can whitelist a single IP or whole subnet. We’re going to whitelist a single /32 IP. Open up the exports file and switch your IP and update the path to your NFS Share
/etc/exports: the access control list for filesystems which may be exported to NFS clients. See exports(5). # Example for NFSv2 and NFSv3: /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_sub> # Example for NFSv4: /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check) /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check) # /mnt/cluster-templates 10.10.10.01/32(rw,sync,no_subtree_check)
rw means clients have access to read and write, sync writes the data to the disk before they are applied and no_subtree_checks speaks for itself.
Export The NFS Share Directory
Finally, we need to export the share directory and restart the NFS Server to complete the setup.
exportfs -a systemctl restart nfs-kernel-server
Enable UFW Firewall
You will want to prevent connections to your NFS share and this can be done by using ufw. Add the IP you have allowed in the exports file. Remember if you have updated your SSH port to also allow that port.
ufw allow from 10.10.10.01/32 to any port nfs ufw allow 22 ufw enable ufw status
You should now see the NFS port of 2049 with your allowed IP next to it. Next, add your new NFS share to the Proxmox GUI. But upon adding the share Proxmox will create the required directories in your NFS server and you can use wget to place templates in these directories. Learn how to download Proxmox templates to your NFS server in our next guide in this series.
How was this article?
You might also like
More from Proxmox
How to create a ZFS Swap Partition
Swap on Linux will assist if your environment is running short on memory. Usually, during setup, most distributions configure a …
How To Fix Proxmox Detected Hardware Unit Hang On Intel NICs
Proxmox Detected Hardware Unit Hang On Intel NICs In some cases, Intel NICs can cause a servers network card to freeze. …
How To Configure Bridged Proxmox Networking
How To Configure Bridged Proxmox Networking In a Routed Proxmox setup, you add your IP addresses to your interface then forward …
[…] our previous article, we created a central Ubuntu NFS Server that is providing our templates over the network. Each host connected to the NFS Server to install […]