Skip to content

demizer/AutoMountNFS

Repository files navigation

AutoMountNFS

A small systemd service I used for mounting NFS shares from a host on the local network using systemd and NetworkManager-dispatch on Arch Linux.

Why

Systemd has support for automounting NFS shares using the x-systemd-automount option. However, if the server is not found on the attached network, then the booting system will hang until systemd gives up trying to mount the missing shares. For wireless hosts, this is not acceptable.

How

With NetworkManager-dispatcher enabled, systemd will activate any scripts contained in /etc/NetworkManager/dispatcher.d. This is where 10-AutoMountNFS is installed. This script calls the AutoMountNFS systemd service which itself calls the automountnfs script that does the actual mounting. The automountnfs script checks for my nfs server, if it is found, then it attempts to mount the nfs shares. If it is not found, then it attempts to umount any mounted shares. Simple.

Additionally, AutoMountNFS uses systemd timers to run every minute. If the NFS host cannot be reached, then the NFS mounts are unmounted.

Install

Development Prerequisites

For development and building using the justfile targets:

  • just - Command runner
  • aurutils - Required for just build-and-ship target
  • pre-commit - For code quality checks

Building

  1. Clone the repository

  2. Using justfile (recommended):

    # Setup development environment
    just setup
    
    # Build package locally
    just build
    
    # Build and ship to alvaone repository (requires aurutils)
    just build-and-ship
  3. Manual build:

    updpkgsums && makepkg -f
  4. Install the package:

    # Using justfile
    just install
    
    # Or manually
    sudo pacman -U automountnfs-*.pkg.tar.xz
  5. Make sure NetworkManager-dispatcher is enabled:

    systemctl enable NetworkManager-dispatcher
  6. Enable and start AutoMountNFS

    systemctl enable AutoMountNFS.timer
    systemctl start AutoMountNFS.timer
  7. Check /var/run/automountnfs for output.

About

Auto mount handling for NFS shares

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published