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

Aaron_Wright at selinc.com Aaron_Wright at selinc.com
Wed Sep 30 08:21:40 PDT 2015


From: Aaron_Wright at selinc.com 
> 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?

I followed dracut's example a bit more, and this works a lot better. Not 
really sure why, but it works now, so yeah!

[Unit]
Description=Test Unit
After=initrd.target
Before=initrd-cleanup.service

[Service]
Type=oneshot
ExecStart=/bin/sh -c "echo hello"

[Install]
RequiredBy=initrd.target
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150930/2f0852b7/attachment.html>


More information about the systemd-devel mailing list