Automount ensures that the NFS share is mounted only when accessed, reducing dependency on startup timing.
sudo apt install nfs-common
Create a file: /etc/systemd/system/mnt-nas-cetakfoto.automount
[Unit]
Description=Automount NFS Share for /mnt/nas/cetakfoto
After=network.target
[Automount]
Where=/mnt/nas/cetakfoto
[Install]
WantedBy=multi-user.target
Create a file: /etc/systemd/system/mnt-nas-cetakfoto.mount
[Unit]
Description=NFS Mount for /mnt/nas/cetakfoto
[Mount]
What=192.168.2.159:/volume1/cetakfoto
Where=/mnt/nas/cetakfoto
Type=nfs
Options=defaults
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable mnt-nas-cetakfoto.automount
sudo systemctl start mnt-nas-cetakfoto.automount
What It Does:
- Automatically mounts the NFS share when it is accessed.
- Ensures minimal disruption if the NAS isn’t ready at boot.