[systemd-devel] waiting for device creation

Lennart Poettering lennart at poettering.net
Sat May 15 17:33:08 PDT 2010

On Fri, 14.05.10 21:20, Malcolm Studd (mestudd at gmail.com) wrote:

> How do you set up a service dependancy on a device?
> I'm trying to get a slackware VM to boot entirely using systemd, and
> one step is running hwclock, which depends on /dev/rtc. /dev/rtc gets
> created when udevd is run, but how do I get the hwclock service t
> depend on /dev/rtc being created? I tried Requires=dev-rtc.device, but
> that does nothing.

In systemd requirement dependencies ("Requires", "Conflicts",
"Requisite") are orthogonal to ordering dependencies ("After",


"a.service requires b.service" means that when a.service is started
b.service is started too, at the same time.

"a.service after b.service" means that when both shall be started,
starting of b.service is delayed until a.service finished starting.

"a.service requires b.service; a.service after b.server" together means
that when a.service is started b.service is started first and a.service
waits until b.service is fully started up.

Now, translating all this to your specific problem: you need to
specify both "After=dev-rtc.device" and "Requires=dev-rtc.device" in
the unit file to get what you want.

Or, actually, you'll need to change more: systemd will only care about
devices that have SYSTEMD_EXPOSE=1 in the udev database. Hence you might
need to add a rule that marks your rtc device like that. We ship
99-systemd.rules which marks tty, network and block devices for exposure
in systemd, which you could take as insipration.

Now, what I don't really understand is why your /dev/rtc device doesn't
exist anyway. Are you loading the rtc driver as a kernel module? If you
do, then stop doing that, it's a useless excercise in making your boot
artificially slow. And if you build that driver into your kernel then
the magic of devtmpfs should make the device node available right-away
so that you don't have to wait for it.


Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/           GnuPG 0x1A015CC4

More information about the systemd-devel mailing list