initramfs creation fails: Default boot partition size too small for some devices.

When running "apk upgrade" on a fresh sxmo 1.3.0 image, the following error is seen when trying to rebuild the initramfs:

-snip-
(129/131) Upgrading sxmo-xdm-config-openrc (0.2.1-r1 -> 0.2.2-r0)
(130/131) Upgrading postmarketos-ui-sxmo (1.3.0-r1 -> 1.3.2-r0)
Executing postmarketos-ui-sxmo-1.3.2-r0.post-upgrade
 * rc-update: sxmo-pinephone already installed in runlevel `default'; skipping
 * rc-update: modemmanager already installed in runlevel `default'; skipping
 * rc-update: xdm already installed in runlevel `default'; skipping
(131/131) Purging llvm10-libs (10.0.1-r1)
Executing busybox-1.33.0-r4.trigger
Executing glib-2.66.7-r1.trigger
Executing eudev-3.2.10-r0.trigger
Executing dbus-1.12.20-r2.trigger
Executing ca-certificates-20191127-r5.trigger
Executing kmod-28-r0.trigger
depmod: WARNING: could not open modules.order at /lib/modules/5.10.12: No such file or directory
depmod: WARNING: could not open modules.builtin at /lib/modules/5.10.12: No such file or directory
Executing fontconfig-2.13.1-r3.trigger
Executing mkfontscale-1.2.1-r1.trigger
Executing postmarketos-mkinitfs-0.22-r0.trigger
==> initramfs: creating /boot/initramfs-postmarketos-allwinner
Scanning kernel module dependencies...
NOTE: ** modprobe warnings below can be ignored ** if your device does not run the
mainline kernel yet (most devices!) or if the related kernel options are enabled
with 'y' instead of 'm' (module).
 - deviceinfo: sun6i_mipi_dsi sun4i_drm pwm_sun4i sun8i_mixer anx7688 gpio_vibra
 - 00-default.modules: dm_crypt ext4 usb_f_rndis
==> kernel: device-tree blob operations
==> kernel: copying dtb allwinner/sun50i-a64-pinephone-1.1 allwinner/sun50i-a64-pinephone-1.2 to boot partition
==> initramfs: creating uInitrd
Image Name:   uInitrd
Created:      Wed Mar 17 23:04:31 2021
Image Type:   AArch64 Linux RAMDisk Image (uncompressed)
Data Size:    1442774 Bytes = 1408.96 KiB = 1.38 MiB
Load Address: 00000000
Entry Point:  00000000
==> kernel: creating uImage
Image Name:   postmarketos
Created:      Wed Mar 17 23:04:32 2021
Image Type:   AArch64 Linux Kernel Image (uncompressed)
Data Size:    19752968 Bytes = 19290.01 KiB = 18.84 MiB
Load Address: 80008000
Entry Point:  80008000
==> initramfs: creating /boot/initramfs-postmarketos-allwinner-extra
gzip: write error: No space left on device
cpio: write error: Broken pipe
Executing postmarketos-base-10-r0.trigger
Configuring a getty on port ttyS0 with baud rate 115200
Executing gtk-update-icon-cache-2.24.33-r0.trigger
OK: 792 MiB in 426 packages 

This is because:

  1. the initramfs-postmarketos-allwinner-extra file is being created on the /boot partition
  2. the new initramfs file is 46M in size, and there's only 33M free on /boot
  3. the new initramfs is 37% larger than the old initramfs(34M).
  4. libLLVM-10.so (62M) was replaced with libLLVM-11.so (89M).

Possible solutions:

  • Default boot_size be increased to at least 160M, with 200M preferable.
  • Create new initramfs files outside boot partition, then overwrite.
  • Trust users of pmbootstrap to predict and use safe value for boot_size option.
  • Have script remove existing initramfs from /boot before building new one

Additional information:

Comparison of libLLVM-##.so files sizes (output from du, in bytes):

62292864        old/usr/lib/libLLVM-10.so
88811280        new/usr/lib/libLLVM-11.so

df -h /boot output prior to upgrade:

Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk0p1  114M   75M   33M  81% /boot

df -h /boot output after (manual) upgrade:

Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk0p1  114M   87M   21M  81% /boot