How to Use systemd for Auto-Mounting Storage Volumes

When it comes to adding additional storage to your Linux workstation or server, mounting volumes with systemd is very effective and is the recommended method going forward. In this video, Jay will show you how to mount both storage volumes and NFS shares via systemd.

YouTube player

Config Files

The following unit files were used in this video (be sure to update them for your environment):

mnt-disk_2.mount

[Unit]
Description=Mount storage volume

[Mount]
What=/dev/disk/by-uuid/e1d1a2dd-dbdd-41e1-bc54-00ff8fe4e6a0
Where=/mnt/disk_2
Type=ext4
Options=rw,noatime

[Install]
WantedBy=multi-user.target

mnt-nfs_share.mount

[Unit]
Description = NFS mount

[Mount]
What=srv-nas-truenas-prod-1.learnlinux.tv:/mnt/volume2/public
Where=/mnt/nfs_share
Type=nfs
Options=defaults
TimeoutSec=5

[Install]
WantedBy=multi-user.target

mnt-nfs_share.automount

[Unit]
Description=NFS Automount

[Automount]
Where=/mnt/nfs_share
TimeoutIdleSec=10

[Install]
WantedBy=multi-user.target