Mount ZFS pool before snapd starts

I have a zpool that has a mountpoint at /var. When I start my server up, the snapd service always throws a bunch of errors and fails to start because it attempts to mount a bunch of things from /var to /snap but it attempts the mounts before the zpool has been mounted so there's nothing in /var yet.

How can I get snapd to attempt these mounts after the zpool has been mounted?


I had a similar issue with libvirtd wanting to start before ZFS had mounted its directory under /var and solved it with a systemd drop-in.

You can make an equivalent drop-in for snapd.service:

ubuntu@vmtest-ubuntu2004:~$ sudo mkdir /etc/systemd/system/snapd.service.d

ubuntu@vmtest-ubuntu2004:~$ cat <<EOF | sudo tee /etc/systemd/system/snapd.service.d/zfs.conf
[Unit]
Requires=zfs.target
After=zfs.target
EOF

ubuntu@vmtest-ubuntu2004:~$ sudo systemctl daemon-reload

This causes systemd to wait to start snapd until ZFS has finished starting up.