[systemd-devel] Minimize systemd for kdump's initramfs

Kairui Song kasong at redhat.com
Fri Jan 3 05:34:22 UTC 2020


On Thu, Jan 2, 2020 at 5:04 PM Zbigniew Jędrzejewski-Szmek
<zbyszek at in.waw.pl> wrote:
>
> On Thu, Jan 02, 2020 at 12:21:26AM +0800, Kairui Song wrote:
> > Some component, like Systemd, have grown by a lot, here is a list of
> > the size of part of binaries along with the binaries they required in
> > F31:
> > /root/image/bin/systemctl
> > 20M     .
> > /root/image/usr/bin/systemctl
> > 20M     .
> > /root/image/usr/bin/systemd-cgls
> > 20M     .
> > /root/image/usr/bin/systemd-escape
> > 20M     .
> > /root/image/usr/bin/systemd-run
> > 20M     .
> > ...
> >
> > There are overlays between the libraries they used so when installed
> > into the initramfs, the total size didn't go too big yet. But we can
> > see the size of systemd binary and libraries it used is much bigger
> > than others.
>
> All systemd binaries will mostly link to the same libraries (because
> they link to a private shared library, which links to various other
> shared libraries). So this "20M" will be repeated over and over, but
> it's the same dependencies.
>
> While we'd all prefer for this to be smaller, 20M should is actually
> not that much...
>
> > And as a compare, from version 219 to 243, systemd's library
> > dependency increased a lot:
> > (v219 is 5M in total, v243 is 20M in total)
>
> This is slightly misleading. Code was moved from individual binaries
> to libsystemd-shared-nnn.so, so if you look at the deps of just a single
> binary, you'll see many more deps (because libsystemd-shared-nnn.so has
> more deps). But the total number of deps when summed over all binaries
> grew much less. A more useful measure would be the size with deps summed
> over all systemd binaries that are installed into your image in v219 and
> v243.
>

Yes, you are right.

I use following method to measure the size of the binary together with
the library it used:
Just call dracut-install to install a binary into an empty folder as
new root, that tool can also take care of resolve and installing the
libraries. The result it like this:

With systemd V243:
[root at localhost test]# for i in /usr/bin/systemd-*; do
/usr/lib/dracut/dracut-install -l -D $(pwd) $i; done
[root at localhost test]# for i in /lib/systemd/systemd-*; do
/usr/lib/dracut/dracut-install -l -D $(pwd) $i; done
[root at localhost test]# /usr/lib/dracut/dracut-install -l -D $(pwd)
/lib/systemd/systemd
[root at localhost test]# /usr/lib/dracut/dracut-install -l -D $(pwd)
/usr/bin/journalctl
[root at localhost test]# /usr/lib/dracut/dracut-install -l -D $(pwd)
/usr/bin/loginctl
[root at localhost test]# /usr/lib/dracut/dracut-install -l -D $(pwd)
/usr/bin/systemctl
[root at localhost test]# /usr/lib/dracut/dracut-install -l -D $(pwd)
/usr/bin/udevadm
[root at localhost test]# du -hs .
34M     .

With V219:
[root at localhost test]# for i in /usr/bin/systemd-*; do
/usr/lib/dracut/dracut-install -l -D $(pwd) $i; done
[root at localhost test]# for i in /usr/lib/systemd/systemd-*; do
/usr/lib/dracut/dracut-install -l -D $(pwd) $i; done
[root at localhost test]# /usr/lib/dracut/dracut-install -l -D $(pwd)
/usr/lib/systemd/systemd
[root at localhost test]# /usr/lib/dracut/dracut-install -l -D $(pwd)
/usr/bin/journalctl
[root at localhost test]# /usr/lib/dracut/dracut-install -l -D $(pwd)
/usr/bin/loginctl
[root at localhost test]# /usr/lib/dracut/dracut-install -l -D $(pwd)
/usr/bin/systemctl
[root at localhost test]# /usr/lib/dracut/dracut-install -l -D $(pwd)
/usr/bin/udevadm
[root at localhost test]# du -hs .
33M     .


So indeed it didn't grow in total.
But kdump's initramfs only need a subset of all binaries, so if I only
install the files needed:


With V243:
[root at localhost test]# for i in systemd systemd-coredump
systemd-cgroups-agent systemd-shutdown systemd-reply-password
systemd-fsck systemd-udevd systemd-journald systemd-sysctl
systemd-modules-load systemd-vconsole-setup; do
/usr/lib/dracut/dracut-install -l -D $(pwd) /usr/lib/systemd/$i; done
[root at localhost test]#
[root at localhost test]# for i in journalctl systemctl udevadm
systemd-run systemd-escape systemd-cgls systemd-tmpfiles; do
/usr/lib/dracut/dracut-install -l -D $(pwd) /usr/bin/$i; done
[root at localhost test]# du -hs .
24M     .

With V219:
[root at localhost test]# for i in systemd systemd-coredump
systemd-cgroups-agent systemd-shutdown systemd-reply-password
systemd-fsck systemd-udevd systemd-journald systemd-sysctl
systemd-modules-load systemd-vconsole-setup; do
/usr/lib/dracut/dracut-install -l -D $(pwd) /usr/lib/systemd/$i; done
[root at localhost test]# for i in journalctl systemctl udevadm
systemd-run systemd-escape systemd-cgls systemd-tmpfiles; do
/usr/lib/dracut/dracut-install -l -D $(pwd) /usr/bin/$i; done
[root at localhost test]# du -hs .
12M     .

That did grow a lot.



More information about the systemd-devel mailing list