1

Env: Kubuntu-20.04.4, nfs-common-1.3.4(apt upgraded).

I have three NFS mounting entries in /etc/fstab that depends on a VPN connection. Only once the VPN come up, these entries can be mounted successfully. But when booting the system always tries to mount them without VPN, and waits for a timeout, so that results every booting waste a long time.

I know that if I remove these mounting entries from /etc/fstab, they would NOT be mounted at boot. But there are a lot of text in fstab for them about NFS configurations, I don't want to input those text manually every time.

Further more, I want to they can be mounted automatically after the VPN comes up, and unmounted quietly when the VPN comes down to prevent from waiting a long time when poweroff.

I have made a systemd service unit to manage the VPN connection, and it works fine.

How to get the NFS mounts work as my expectation?

1
  • Which VPN solution are you using? I know of StrongSwan that it provides a way to add a script that can be used to handle various stuff when the VPN is coming up or going down, so this same mechanism could viably be used to mount/unmount NFS shares depending on the tunnel's state.
    – Robidu
    Commented Sep 8, 2022 at 21:43

1 Answer 1

1

I would recommend looking into autofs:

Auto-mounts are mounted only as they are accessed, and are unmounted after a period of inactivity. Because of this, automounting NFS/Samba shares conserves bandwidth and offers better overall performance compared to static mounts via fstab.

This also makes it more tolerant of the NFS server becoming available after the intial mount attempt.

You could also try adjusting timeo= and retry=:

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Sep 8, 2022 at 21:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .