<tt><font size=2>From: Aaron_Wright@selinc.com <br>
> I'm rolling my own initrd, and I'm trying to run a oneshot service
<br>
> in initrd just before the switch root happens. I added this unit to
<br>
> the initrd and enabled it. <br>
> <br>
> [Unit] <br>
> Description=Test Unit <br>
> Requires=initrd-fs.target <br>
> After=initrd-fs.target <br>
> <br>
> [Service] <br>
> Type=oneshot <br>
> ExecStart=/bin/sh -c "echo hello" <br>
> <br>
> [Install] <br>
> RequiredBy=initrd-switch-root.target <br>
> <br>
> The service does run, and I get "hello" in the journal,
but then my <br>
> /var mount doesn't mount. I'm having a hard time correlating the two<br>
> seeming different things. The var.mount unit complains about a <br>
> failed dependency. It's dependency is dev-disk-by\x2dpartlabel-<br>
> varfs.device, which has no logs, is loaded, but inactive (dead). <br>
> There is also a fsck dependency that is loaded, but inactive (dead).
<br>
> <br>
> Without this simple oneshot service in initrd, everything works <br>
> fine, fsck checks varfs and /var is mounted. Thoughts? <br>
> <br>
> Is there a better way to position a service to just before switch
root?</font></tt>
<br>
<br><tt><font size=2>I followed dracut's example a bit more, and this works
a lot better. Not really sure why, but it works now, so yeah!</font></tt>
<br>
<br><font size=2 face="Courier New">[Unit]<br>
Description=Test Unit<br>
After=initrd.target<br>
Before=initrd-cleanup.service<br>
<br>
[Service]<br>
Type=oneshot<br>
ExecStart=/bin/sh -c "echo hello"<br>
<br>
[Install]<br>
RequiredBy=initrd.target<br>
</font>