Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 Aug 1 '13 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 – luaduck Aug 1 '13 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 Aug 5 '13 at 12:46
Might this have anything to with your udev rules? I'm willing to bet there's some connection – mikeserv Mar 12 '14 at 16:06

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.

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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