On Mon, 28.09.15 15:40, aaron_wri...@selinc.com (aaron_wri...@selinc.com) wrote:
> I'm rolling my own initrd, and I'm trying to run a oneshot service in > initrd just before the switch root happens. I added this unit to the > initrd and enabled it. > > [Unit] > Description=Test Unit > Requires=initrd-fs.target > After=initrd-fs.target > > [Service] > Type=oneshot > ExecStart=/bin/sh -c "echo hello" > > [Install] > RequiredBy=initrd-switch-root.target > > The service does run, and I get "hello" in the journal, but then my /var > mount doesn't mount. I'm having a hard time correlating the two seeming > different things. The var.mount unit complains about a failed dependency. > It's dependency is dev-disk-by\x2dpartlabel-varfs.device, which has no > logs, is loaded, but inactive (dead). There is also a fsck dependency that > is loaded, but inactive (dead). Well, the var.mount backing device never appeared then. > Without this simple oneshot service in initrd, everything works fine, fsck > checks varfs and /var is mounted. Thoughts? Well, that service does not set DefaultDependencies=no, hence will be ordered after local-fs.target, and hence after var.mount... but you also use it in earliest boot and effectively order it before initrd-switch-root.target. Which means you have a cyclic dep, as you have a service that wants to be in late boot, but is ordered into early boot... systemd should log about cyclic deps like this. Anyway, long story short: you must set DefaultDependency=no for all initrd and early-bird services, as otherwise your service will be placed into late boot, via the implicit default deps, and that makes no sense for the initrd. Lennart -- Lennart Poettering, Red Hat _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel