You can mount the remote NFS shares automatically at boot by adding them to /etc/fstab
file on the client.
Open this file with root privileges in your text editor:
sudo nano /etc/fstab
Copy
At the bottom of the file, add a line for each of your shares. They will look like this:
/etc/fstab
. . . host_ip:/var/nfs/general /nfs/general nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0 host_ip:/home /nfs/home nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
Note: You can find more information about the options you are specifying here in the NFS man page. You can access this by running the following command:
man nfs
Copy
The client will automatically mount the remote partitions at boot, although it may take a few moments to establish the connection and for the shares to be available.
Unmounting an NFS Remote Share
If you no longer want the remote directory to be mounted on your system, you can unmount it by moving out of the share’s directory structure and unmounting, like this:
cd ~ sudo umount /nfs/home sudo umount /nfs/general
Copy
Take note that the command is named umount
not unmount
as you may expect.
This will remove the remote shares, leaving only your local storage accessible:
df -h
Copy
OutputFilesystem Size Used Avail Use% Mounted on tmpfs 198M 972K 197M 1% /run /dev/vda1 50G 3.5G 47G 7% / tmpfs 989M 0 989M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock /dev/vda15 105M 5.3M 100M 5% /boot/efi tmpfs 198M 4.0K 198M 1% /run/user/1000
If you also want to prevent them from being remounted on the next reboot, edit /etc/fstab
and either delete the line or comment it out by placing a #
character at the beginning of the line. You can also prevent auto-mounting by removing the auto
option, which will allow you to still mount it manually.