[systemd-devel] Exploring Minimal Systemd in Initramfs for Faster Boot
Lennart Poettering
lennart at poettering.net
Mon Sep 30 08:35:41 UTC 2024
On Mi, 25.09.24 21:06, Brian Masney (bmasney at redhat.com) wrote:
> On Wed, Sep 25, 2024 at 03:53:36PM +0000, Dharma.B at microchip.com wrote:
> > yes something similar to this, I will experiment this and get back to you.
> >
> > and I think since the egt service and its libraries depend on the full
> > rootfs, integrating initramfs might not provide significant benefits in
> > terms of faster launch time. The time saved by using an initramfs to
> > launch basic services earlier would likely be offset by the delay in
> > mounting the root filesystem, which is necessary for accessing the egt
> > libraries.
>
> There are some drawbacks to putting your early service in the initramfs
> and having it persist across the switch root to when systemd is started
> again from the root filesystem.
>
> - The initrd is a cpio archive, and increasing the size of the initrd is
> going to increase the kernel boot time since it will need to
> uncompress and extract the larger cpio archive.
>
> - Any services started from the initrd will be started before the
> SELinux policy is loaded. Services started from the initrd will run
> with the kernel_t label.
>
> - Services started from the initrd can't depend on almost anything like
> mounts, devices, services, dbus, etc so it's difficult to develop
> software of any complexity.
>
> - Adding all of these dependencies to the initrd is only going to move
> the timing bottlenecks booting from the root filesystem to the initrd.
>
> - Directives like Restart=always will likely not work as expected.
There's more: anything that keeps running from the initrd will keep
the files it runs from pinned, and they are not reclaimable
memory. During the initrd→host transition we'll empty the intird tmpfs
(i.e. delete all files), which means you are running a process of
entirely deleted files, which is a bit weird.
While we do support binaries that stay running from the initrd, it's
typically something I'd suggest people to avoid, and if they do it
anyway, then at least only for a short time (i.e. terminate once boot
is complete or so)
Lennart
--
Lennart Poettering, Berlin
More information about the systemd-devel
mailing list