Skip to content

Instantly share code, notes, and snippets.

@indraAsLesmana
Created January 10, 2025 23:05
Show Gist options
  • Save indraAsLesmana/79dd476d3270a7b42d941d26813ca2b9 to your computer and use it in GitHub Desktop.
Save indraAsLesmana/79dd476d3270a7b42d941d26813ca2b9 to your computer and use it in GitHub Desktop.

NFS Auto Mount Guide

Automount ensures that the NFS share is mounted only when accessed, reducing dependency on startup timing.

Steps to Set Up NFS Auto Mount

1. Install Systemd Autofs

sudo apt install nfs-common

2. Create a Systemd Automount Unit:

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

3. Create a Mount Unit:

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

4. Reload and Enable Automount:

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment