Systemd is a better solution for mounts as it enables you to stage dependencies when mounting.
ie: By using the After=
directive in the .mount file you can ensure a mount for a LUN doesn't happen until after it's first been connected. Here's a snippet from a script I wrote to automate mounting remote storage:
cat <<EOF> /etc/systemd/system/mnt-$ISCSIDISKMOUNTFOLDER.mount
[Unit]
Description=iSCSI Disk
After=connect-luns.service
[Mount]
What=/dev/disk/by-uuid/$(ls -al /dev/disk/by-uuid | grep $ISCSIDEVICE | awk '{print $9}')
Where=/mnt/$ISCSIDISKMOUNTFOLDER
Type=$FILESYSTEM
[Install]
WantedBy=multi-user.target
EOF
The mount was happening before the service "connect-luns.service" started, but once I plugged the service into the After=
directive, the storage now rose-up correctly on boot. Systemd offered a very simple & elegant way of managing dependencies in respect to mounting remote storage in this use case.
Exception:
In some cases you might not be able to use SystemD to mount your storage, a very notable exception being Alpine Linux which still uses SysVinit and an /etc/fstab
to maintain a tiny profile. Alpine Linux is popular in the container world. So there is still a place for /etc/fstab
believe it or not even in the all-singing, all-dancing age of SystemD
/etc/fstab
has the, for me, distinct advantage of managing mounts in the one file.../etc/fstab
for years without any concerns/problems. Even with NFS mounted partitions... As long as you know how to maintain your configuration, it is totally fine.