random-archer / mkinitcpio-systemd-tool

Provisioning tool for systemd in initramfs (systemd-tool)
https://www.archlinux.org/packages/community/any/mkinitcpio-systemd-tool/
Other
112 stars 27 forks source link

initrds are much larger than usual #69

Closed dvzrv closed 2 years ago

dvzrv commented 4 years ago

When using mkinitcpio-systemd-tool the initrd images are extremely large (~ 3x the size!) in comparison to when using mkinitcpio-netconf + mkinitcpio-dropbear.

When gzip compressing the images I still end up with 86Mb large initrds:

-rw-r--r--  1 root root  83M Jun 17 20:26 initramfs-linux-hardened.img

In comparison, the initrds created with mkinitcpio-netconf + mkinitcpio-dropbear are around 26Mb.

-rw-r--r--  1 root root  26M Jun 11 13:03 initramfs-linux-hardened.img

Are the mkinitcpio scripts somehow triggering a fallback style image being built?

This is way too big and really not ideal for systems where space matters and/or where the /boot partition size is constrained.

dvzrv commented 4 years ago

An indicator that somehow the hook drags in all sorts of modules are the following warnings triggered by it during mkinitcpio:

==> WARNING: Possibly missing firmware for module: mt7603e
==> WARNING: Possibly missing firmware for module: wcn36xx
==> WARNING: Possibly missing firmware for module: orinoco_usb
==> WARNING: Possibly missing firmware for module: p54usb
==> WARNING: Possibly missing firmware for module: p54spi
==> WARNING: Possibly missing firmware for module: p54pci
==> WARNING: Possibly missing firmware for module: prism54
==> WARNING: Possibly missing firmware for module: b43legacy
==> WARNING: Possibly missing firmware for module: b43
==> WARNING: Possibly missing firmware for module: atmel
==> WARNING: Possibly missing firmware for module: at76c50x_usb
==> WARNING: Possibly missing firmware for module: rtl8723ae
==> WARNING: Possibly missing firmware for module: ipw2200
==> WARNING: Possibly missing firmware for module: ipw2100
==> WARNING: Possibly missing firmware for module: rsi_sdio
==> WARNING: Possibly missing firmware for module: rsi_usb
==> WARNING: Possibly missing firmware for module: zd1201
==> WARNING: Possibly missing firmware for module: zd1211rw
==> WARNING: Possibly missing firmware for module: lantiq_gswip
==> WARNING: Possibly missing firmware for module: softing_cs
Andrei-Pozolotin commented 4 years ago
  1. you mean, you compare non-systemd vs systemd-based initramfs image sizes? well, systemd + dependencies itself is about 50MB

  2. on the other hand, my local initramfs are "moderately" small: 20 MB / 50 MB

    19540 -rwxr-xr-x  1 root root 20005797 Jun  9 17:57 initramfs-linux.img
    53320 -rwxr-xr-x  1 root root 54598199 Jun  9 17:57 initramfs-linux-fallback.img
  3. the warnings triggered are due to adding "checked network modules" https://github.com/random-archer/mkinitcpio-systemd-tool/blob/master/src/initrd-network.service

    # provision discovered network kernel modules
    InitrdCall=add_checked_modules /drivers/net/
  4. please look inside your initramfs images to confirm if any extraneous items are present

    lsinitcpio -x /boot/initramfs-linux.img
Andrei-Pozolotin commented 4 years ago

assume resolved

dvzrv commented 4 years ago

This is not really solved. I just don't have much time to work on this right now.

xz-compressed I'm still at 48-50Mb. Maybe something similar to the autodetect hook can help here somehow?

Here is the output of lsinitcpio -av on the hardened kernel initramfs: initramfs-linux-hardened.txt

And here the output of lsinitcpio -v for the same image: initramfs-linux-hardened-files.txt

makuhama commented 2 years ago

@dvzrv make sure to put autodetect before systemd systemd-tool in the HOOKS array in mkinitcpio.conf. At least in my case this reduced the size of initrd from 97825323 to 32932110.

dvzrv commented 2 years ago

@makuhama :man_facepalming:

Thanks! That was it! :)