How to Share Folders Using NFS
If you want to share storage on a virtual machine, you first need to prepare the volume and set up server NFS.
Note
A NFS share connection is working in a local network only.
Install NFS Server on Server System Side
sudo apt install nfs-kernel-server
Choose an NFS export directory. In this example, it is /mnt/share - but of course you can chose a different one:
sudo mkdir /mnt/share
Specify the appropriate rights for the directory (in the example: read/write):
sudo chmod 777 /mnt/share/
Set up NFS share access for the desired client systems. The permissions for accessing the NFS server are defined in the /etc/exports file. Open this file with the text editor:
$ sudo nano /etc/exports
You can provide access for a single client, multiple clients or an entire subnet. To provide access for a single client, add the following line to the export file and save it:
/mnt/share 10.x.x.x/255.255.255.0(rw,sync,no_subtree_check,no_root_squash)
The IP address above (10.x.x.x) should be changed to the local IP address of the desired client and can be found in OpenStack Dashboard.
Note
Beware of using the public IP address. Using NFS is not very secure and should only be used inside the project
After granting access to the desired client systems, you need to export the NFS share directory and restart the NFS kernel server for the changes to come into effect:
$ sudo exportfs -a
Restart NFS services:
$ sudo systemctl restart nfs-kernel-server
Install NFS Client on Client System Side
Update the system packages and repositories before installation:
$ sudo apt update
Install nfs-common packages:
$ sudo apt install nfs-common
Next, create a mount point on which you will mount the NFS share from the NFS server:
$ sudo mkdir /mnt/clientshare
Change permissions:
chmod 777 /mnt/clientshare
Mount server shared directory:
sudo mount -o 10.x.x.x:/mnt/share /mnt/clientshare
Now we can check in the system if a mounted NFS folder exists:
df -h