I would like to make sure that a ZFS mountpoint is available before service managed by systemd starts. Therefore I'd use the After= stanza in the systemd unit. But, what to write as argument?

I'm using a local installation of ZFS because of ongoing performance issues with the shipped version and import the only pool with

Description=ZFS pool import for source installations of ZFS

ExecStart=/usr/local/sbin/zpool import -d /dev data


because I never found any useful documentation of systemd support on Ubuntu and it seems to be targeted by devs only now.

However, on another system I also experience trouble with the built-in resources, e.g. zfs-mount.service is loaded and running even if no pools are imported and thus no mounts could have been successful.

Is there a target that I can make my services depend on in order to start only after the mountpoint is available and refuse to start if the whole ZFS or just the mountpoint failed to initialize (and that I could copy for my local installation)?

I'm using Ubuntu 17.10.


System Defaults

There is a lot of magic here, but on Ubuntu 18.04 the answer generally seems to be zfs.target, which is listed as WantedBy all of the various zfs-*.services (mount, modprobe, etc.). You will see this if you peruse through

more /lib/systemd/system/zfs* | less

You may notice that there is also a zfs-import.target which is satisfied after zpool import has run, but before filesystems are mounted.

In my case, though, there are other steps that need to happen first (encrypted block device mapping, for example) so these will not work out of the box for me.

Specific Mount Points

For specific mount points I would recommend not relying on the general zfs.target, but rather add your own service (perhaps with Wants=zfs.target) that checks the status of the specific mounts your system relies upon. For example, if you rely on /blah/my/zfs/mount being mounted, just create a service for that which can check the zfs mount status before returning, perhaps with

zfs get mounted blah/my/zfs/mount | grep yes



Description=ZFS mount blah/my/zfs/mount

ExecStart=/sbin/zfs get mounted blah/my/zfs/mount | grep yes


And then your other services can depend on this one.

  • Strange that there's no easier way to do this which would spare the extra unit. – Karl Richter Aug 30 '18 at 9:07
  • 1
    A dependency on zfs.target, zfs-import.target isn't deterministic enough for my taste (they succeed, no matter whether the pool was imported or not), therefore I created a Requires=zfs-pool-import-poolname.service dependency, changed the Type to simple and am polling the availability with Restart=on-failure RestartSec=5. The zpool availability check is performed with zpool status. – Karl Richter Aug 30 '18 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.