[systemd-devel] Simple oneshot service before switching root leads to no /var mount

Aaron_Wright at selinc.com Aaron_Wright at selinc.com
Mon Sep 28 15:40:09 PDT 2015


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).

Without this simple oneshot service in initrd, everything works fine, fsck 
checks varfs and /var is mounted. Thoughts?

Is there a better way to position a service to just before switch root?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150928/5f2e81b7/attachment.html>


More information about the systemd-devel mailing list