Hi all, I just spent some time getting this to work the way I want to and I wanted to share some stuff I found that might save other people some time.
Use these options (on top of the ones you need for your credentials)
- x-systemd.automount
- This will make it so that your network share is only mounted when you try to use it, instead of taking precious time during boot
- x-systemd.requires=tailscaled.service
- This will make it so that the share is only mounted after tailscale is active, but MOST IMPORTANTLY it will make it so that the share is unmounted before tailscale is stopped during shutdown. This is very important because tailscale is usually stopped before. If tailscale is stopped, your shutdown process will be much longer because it gets stuck while trying to unmount a network share that is not reachable anymore.
- x-systemd.idle-timeout=60
- This will unmount the network share a minute after you stopped using it, so that it won’t take time during shutdown
- x-systemd.mount-timeout=30
- This is here because if the network share is mounted but unreachable during shutdown, at least you’re not gonna have to wait for minutes before it actually shuts down
Don’t use these options:
- _netdev
- Not needed, systemd already knows it is a network device because it is using CIFS. Also there’s no point since we already specify that it relies on tailscale
- auto or noauto
- These have no effects if automount is enabled
- nofail
- Very important that you do not use it, because nofail will not ensure that this directory is unmounted before tailscale is stopped. You will have to wait in the shutdown screen.
As a complete example, here’s the line I appended to the fstab
//minipc/shared /var/home/shared cifs username=yourusername,password=yourpassword,uid=yourusername,gid=yourgroup,x-systemd.automount,x-systemd.requires=tailscaled.service,x-systemd.idle-timeout=60,x-systemd.mount-timeout=30 0 0
Credit to: u/XLNBot and his post.