===============
= ptrcnull.me =
===============
writeups and other stuff

OpenRC: Start services after login prompt

I’m using Alpine Linux as my main OS on desktop. As I don’t use any display manager/greeter such as LightDM’s, I noticed that it takes quite a bit of time to actually get the login prompt. After a while of searching through logs, I realized that some services - primarily chronyd - wait a few seconds for e.g. getting a response from NTP server and don’t exit the start function immediately after starting the process. I tried googling for a solution and found this Unix StackExchange answer, yet it didn’t solve my problem.

But, after reading Alpine User Handbook’s page on OpenRC, I got the idea that it could be solved with a bit of tinkering with custom runlevels.

So, the final solution was:

  • create a custom runlevel (I chose the name “async”, but it doesn’t matter)
sudo mkdir /etc/runlevels/async
sudo rc-update add -s default async
  • remove services from default and add them to async
sudo rc-update del chronyd
sudo rc-update add chronyd async
  • add changing runlevel to async to inittab

Add this line to /etc/inittab:

::once:/sbin/openrc async

After rebooting, services from default runlevel will still block agetty from running (after all, it has the wait label in inittab), but services from async will start separately.