Right now I'm using zfsonlinux on Fedora 19, and it works excellently. Mounting works at bootup as planned using the initscript (included with zfs) that systemd calls, but there's a pretty significant flaw: ZFS is mounted way, WAY too late during boot, to the point that transmission and other services get very lost without /zfs mounted and can't recover, hence failing them.

What I'm after is a way to get systemd to fire up the script before doing anything else. I know how to do it using initscripts (just set it to a lower runlevel, say 2), but I haven't the foggiest when it comes to doing it with systemd's target system.

I've tried setting things in the services that require zfs to be up, but it doesn't work, barring Type=idle (but there must be a better way of doing it regardless):


And for reference's sake, here's the initscript provided by Fedora. Due to the nature of how ZFS mounts on linux (?), I can't just plop an entry into fstab and be done with it, it has to be mounted using commands.

  • untested but I believe you need to update your multi-user.target to be dependent on your service, assuming that your other services start after multi-user.
    – BitsOfNix
    Commented Aug 1, 2013 at 22:34
  • @alexandre-alves I'm not sure if targets can fire initscripts (if they can, then smashing), and ideally I want to avoid having to rewrite the entire mount script to make it systemd ready
    – duck.
    Commented Aug 1, 2013 at 23:13
  • Just a thought, but could it be that your zfs service is treated as a daemon, instead of a task? I.e. that the script got started before the other services which depend on it, but hadn't completed yet?
    – MvG
    Commented Aug 5, 2013 at 12:46
  • Might this have anything to with your udev rules? I'm willing to bet there's some connection
    – mikeserv
    Commented Mar 12, 2014 at 16:06

2 Answers 2


systemd has a specific directive for this case, called RequiredMountsFor; see man systemd.directives.

The usage would be RequiresMountsFor=[mountpoint], e.g. RequiresMountsFor=/zfs.

Key question might be whether you really need to reflect an "anything else" condition, like your Q states. I think the idea is to use these dependencies as selectiviely as possible to support finding the optimal sequence and maximum parallelisation.


I'll try to answer as best as I can, not that familiar with systemd.

The script that is provided is just a standard one, so you can always start it with script_name start.

From what I've seen in the man pages of systemd, you can define dependencies and the best one would be to use Before and After specific targets. Looking at the files there is a alias from runlevel 2 3 and 4 to be always multiuser.target.

if you do systemctl list-dependencies basic.target you can easily figure out where you want your service to start.

Description=my Service

ExecStart=/path/to/script start
ExecStop=/path/to/script stop

save the file example /usr/lib/systemd/myservice.service. systemctl enable myservice.service.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .