Automount of disks

Lars Jönsson 2024-09-02

Mount remote volumes automatically.

Overview

Systemd is responsible for mounting disks. If a remote disk is not available at boot, mount will fail and the disk will remain unmounted. By using the automount feature of systemd, disks can automatically be mounted at access.

NOTE Disks will not be mounted at boot when the automount feature is enabled. They will be mounted at access.

Configuration

The x-systemd.automount option should be added to all disks that should be automamatically mounted.

//<IP>/doc      /opt/doc       cifs  credentials=/etc/win-nas.creds,_netdev,x-systemd.automount  0 0
<IP>:/programs  /opt/programs  nfs   defaults,x-systemd.automount                                0 0

Reboot Linux to reload the systemd daemon and start the automount services or skip the reboot and do it manually.

Each automount service is named after its mount path. The path /opt/doc will have the service name opt-doc.automount, /opt/programs will have opt-programs.automount etc.

sudo reboot

  --- OR ---

sudo systemctl daemon reload
sudo systemctl start opt-doc.automount
sudo systemctl start opt-programs.automount