To prevent NFS mounts from attempting to mount while your system is offline and disable retry attempts in Ubuntu, you can use the noauto
option in conjunction with the retry=0
option in your /etc/fstab
file. Here's how to do it:
Open a terminal window.
Edit the /etc/fstab file using your preferred text editor. You may need superuser privileges, so use sudo:
sudo nano /etc/fstab
.Locate the line for the NFS mount you want to modify. It will look something like this:
server:/export /mnt/nfs nfs defaults 0 0
Add the noauto and retry=0 options to the list of options. The modified line will look like this:
server:/export /mnt/nfs nfs noauto,retry=0 0 0
Save the file and exit the text editor.
After making this change, the NFS share will not be automatically mounted at boot, and it will not attempt to retry if the server is offline. You can manually mount it when needed using the mount command or by accessing the directory. For example:sudo mount /mnt/nfs
Photo by Jordan Harrison