[systemd-devel] Minimize systemd for kdump's initramfs
Kairui Song
kasong at redhat.com
Wed Jan 1 16:21:26 UTC 2020
Hi all,
I noticed there is a Fedora minimization project which seems could be
a bit related to the thing I'm trying to do, and this could be a
generic topic.
What I'm trying to do is reduce the initramfs size used for kdump.
Kdump loads a crash kernel and kdump initramfs image in a prereseved
memory region, which get booted when current kernel crashed and
perform crash dump. The prereserved memory is limited, so initramfs
shouldn't go too big.
Kdump in Fedora use Dracut to create bootable initramfs, just hook the
final step to do kdump things instead of switch root. And to reduce
the size only the binaries and drivers required to boot and perform
kdump on current machine is installed. So long it have been working
very well.
But problem is Dracut works by reusing binaries and libraries from the
currently running system, and many userspace binaries and libraries is
keep growing and using more space. So the initramfs is also growing.
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/bash
4.8M .
/root/image/bin/echo
3.4M .
/root/image/bin/kmod
7.5M .
/root/image/bin/mkdir
4.5M .
/root/image/bin/mount
5.3M .
/root/image/bin/sh
4.8M .
/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.
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)
Version 243:
[root at localhost ~]# systemctl --version
systemd 243 (v243.4-1.fc31)
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP
+LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS
+KMOD +IDN2 -IDN +PCRE2 default-hierarchy=unified
[root at localhost ~]# ldd /usr/bin/systemctl
linux-vdso.so.1 (0x00007ffe739a3000)
libc.so.6 => /lib64/libc.so.6 (0x00007fe2bbd63000)
libsystemd-shared-243.so =>
/usr/lib/systemd/libsystemd-shared-243.so (0x00007fe2bba8d000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fe2bba73000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe2bbf73000)
librt.so.1 => /lib64/librt.so.1 (0x00007fe2bba68000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007fe2bba61000)
libacl.so.1 => /lib64/libacl.so.1 (0x00007fe2bba56000)
libcryptsetup.so.12 => /lib64/libcryptsetup.so.12 (0x00007fe2bb9e3000)
libgcrypt.so.20 => /lib64/libgcrypt.so.20 (0x00007fe2bb8c5000)
libip4tc.so.2 => /lib64/libip4tc.so.2 (0x00007fe2bb8bb000)
libkmod.so.2 => /lib64/libkmod.so.2 (0x00007fe2bb8a1000)
libmount.so.1 => /lib64/libmount.so.1 (0x00007fe2bb83e000)
libseccomp.so.2 => /lib64/libseccomp.so.2 (0x00007fe2bb7f1000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fe2bb7c2000)
libidn2.so.0 => /lib64/libidn2.so.0 (0x00007fe2bb7a0000)
liblzma.so.5 => /lib64/liblzma.so.5 (0x00007fe2bb777000)
liblz4.so.1 => /lib64/liblz4.so.1 (0x00007fe2bb756000)
libblkid.so.1 => /lib64/libblkid.so.1 (0x00007fe2bb6ff000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fe2bb6dd000)
libattr.so.1 => /lib64/libattr.so.1 (0x00007fe2bb6d3000)
libuuid.so.1 => /lib64/libuuid.so.1 (0x00007fe2bb6c9000)
libdevmapper.so.1.02 => /lib64/libdevmapper.so.1.02 (0x00007fe2bb66c000)
libssl.so.1.1 => /lib64/libssl.so.1.1 (0x00007fe2bb5d6000)
libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007fe2bb2f6000)
libargon2.so.1 => /lib64/libargon2.so.1 (0x00007fe2bb2ec000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fe2bb2e3000)
libjson-c.so.4 => /lib64/libjson-c.so.4 (0x00007fe2bb2d1000)
libgpg-error.so.0 => /lib64/libgpg-error.so.0 (0x00007fe2bb2ae000)
libpcap.so.1 => /lib64/libpcap.so.1 (0x00007fe2bb262000)
libz.so.1 => /lib64/libz.so.1 (0x00007fe2bb248000)
libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007fe2bb1ba000)
libunistring.so.2 => /lib64/libunistring.so.2 (0x00007fe2bb034000)
libudev.so.1 => /lib64/libudev.so.1 (0x00007fe2bb006000)
libm.so.6 => /lib64/libm.so.6 (0x00007fe2baec0000)
Version 219:
[root at localhost test]# systemctl --version
systemd 219
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP
+LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 -SECCOMP +BLKID +ELFUTILS
+KMOD +IDN
[root at localhost test]# ldd /bin/systemctl
linux-vdso.so.1 => (0x00007fffc407f000)
librt.so.1 => /lib64/librt.so.1 (0x00007f70255bd000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f7025396000)
liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f7025170000)
liblz4.so.1 => /lib64/liblz4.so.1 (0x00007f7024f5b000)
libgcrypt.so.11 => /lib64/libgcrypt.so.11 (0x00007f7024cda000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007f7024ad5000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f70248bf000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f70246a3000)
libc.so.6 => /lib64/libc.so.6 (0x00007f70242d5000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7025a72000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f7024073000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f7023e6f000)
libgpg-error.so.0 => /lib64/libgpg-error.so.0 (0x00007f7023c6a000)
libattr.so.1 => /lib64/libattr.so.1 (0x00007f7023a65000)
Kdump in Fedora relies heavily on Dracut, and Dracut relies on
systemd. But kdump only expect systemd to start some services. I think
there might be many features not needed by kdump being brought in.
Is there any way to have a smaller systemd binary that is just enough
to boot the initramfs into the stage before switch-root?
--
Best Regards,
Kairui Song
More information about the systemd-devel
mailing list