Stop an NFS share in fstab from hanging boot and shutdown
The diagnosis is accurate: hard is the NFS default and does retry indefinitely, and the record correctly notes that retrans does not bound a hard mount and that soft trades hangs for EIO. The fstab line and options are valid. The activation step is the weak part: systemctl restart remote-fs.target is an unreliable way to pick up a newly generated automount unit (targets carry no processes and mounts are only Wanted by them), so users following this often see nothing happen and conclude the fstab entry is wrong. Start the generated automount unit by name.
soft NFS mounts can cause silent data corruption. The man page recommends them only when client responsiveness matters more than data integrity. Never use soft for a share you write to.
Symptom
With an NFS share in /etc/fstab, boot stalls for minutes on A start job is running for /mnt/nas whenever the server is off or you are away from that network, and shutdown hangs on A stop job is running for /mnt/nas. Once the server disappears mid-session, any process touching the mount becomes unkillable in D state and df hangs.
Cause
NFS mounts default to hard, meaning NFS requests are retried indefinitely rather than failing. That is the primary cause of NFS-related hangs. In fstab a network filesystem is also pulled into remote-fs.target as a hard requirement, so systemd blocks boot waiting for it and blocks shutdown trying to unmount a server that is already unreachable.
Fix
fstab line as written is correct:
nas.local:/export/media /mnt/nas nfs4 noauto,nofail,_netdev,x-systemd.automount,x-systemd.idle-timeout=600,x-systemd.mount-timeout=10,timeo=100,retrans=2 0 0
Activate it by starting the generated unit explicitly rather than restarting the target:
sudo systemctl daemon-reload
systemd-escape -p --suffix=automount /mnt/nas # -> mnt-nas.automount
sudo systemctl start mnt-nas.automount
systemctl status mnt-nas.automount --no-pager
ls /mnt/nas # triggers the mount on first access
To clear a mount that is already wedged (lazy detach is the part that works when the server is gone):
sudo umount -l /mnt/nas
Only add soft if you accept that the client returns EIO after retrans retransmissions instead of retrying forever. That risks silent data loss on writes, so keep hard for anything you write to.
Verify
systemctl list-units 'mnt-nas.*' shows an .automount unit active and the .mount unit inactive until first access. Power the server off, then reboot: boot reaches the greeter without stalling, and systemctl poweroff completes without a stop job.