4. How to connect a linux server to NFS share?
On all linux OSes, disk mounting configuration is written in the text file under the path /etc/fstab
. We need to edit this file, in order to mount the network share into the linux server
Prerequisites:
On Ubuntu/Debian Systems:
Enter sudo apt install nfs-common nano
and confirm the install.
Breakdown:
nfs-common
is a package that allows NFS shares to be mountnano
is a beginner friendly CLI text editor app
On Fedora Server:
Enter sudo dnf install nano
and confirm the install. Command Breakdown is same as before
Steps:
You now need to create the directory where you will mount the shared NFS folder: mkdir /mnt/whatever_path
Normally, I would use the /mnt/whatever_path
to mount external storages.
Now enter, sudo nano /etc/fstab
. You should get a window as shown below:
On the text file, press enter to move the cursor onto a new line
Next enter everything on one line in the following format:
10.0.0.48:/mnt/twotbpool/main/Vaultwarden_Backup /media/vwbackup nfs defaults 0 0
Breakdown:
10.0.0.48:/mnt/twotbpool/main/Vault...
is the path specified on the truenas server, and its ip/media/vwbackup
is local path created on the linux server, where the shared NFS folder will be mounted tonfs
specifies the file format (in this case its nfs)defaults
specifies the OS to use default mounting settings0 0
recommended config for almost all nfs mounts
After that is done, your window should look like this:
Now Press Ctrl + X
,y
and Enter
to save the text file.
Enter sudo mount -a
, and if everything went well, no error should be outputted and your terminal should look like this:
Next, Enter df -h
and see if your share shows up, along with the size of the free space:
With this, everything should be configured! To test if you have write access, cd
into the mounted directory and simply run touch trial.txt
and see if an error is thrown. If not then it has worked.
To verify file is present, type ls
and see if the file is still there!
And With that you have successfully connected an NFS share onto your Linux Server
No Comments