Skip to main content

Posts

Showing posts from March, 2023

Systemd - Mount filesystems on demand

I find myself using systemd's built-in functions more and more. This time, automounts and mounts which I prefer to autofs due to systemd-automount's simplicity. Talking about simplicity, all it takes for a automount is a unit-file (.automount), reloading the systemd daemon and enable the automount unit. Here's a quick reference on how to set it up using a nfs-share but keep in mind that automounts work with pretty much any other filesystem aswell. Ensure a nfs-share exists on your nfs server (any nfs-server will do): [root@nfs ~]# cat << EOF >> /etc/exports /var/nfs/data server.archyslife.lan(rw,secure,sync,no_root_squash,nohide) EOF On the server that's going to be mounting the share, create the systemd-mount unit first: [root@server ~]# cat << EOF > /etc/systemd/system/var-backup-data.mount [Unit] Description=Mount for /var/backup/data [Mount] What=nfs.archyslife.lan:/var/nfs/data Where=/var/backup/data Type=nfs Opt