From 53a9cc2c1dfa5670e7f646f8e72684b88c3ee4b7 Mon Sep 17 00:00:00 2001 From: Johan Gunnarsson Date: Tue, 25 Jul 2023 19:47:59 +0200 Subject: [PATCH] Reduce initramfs size This will reduce compressed initramfs size on Ubuntu from 89 MB to 28 MB. --- .../etc/initramfs-tools/conf.d/modules.conf | 1 + .../initramfs-tools/conf.d/compression.conf | 2 ++ .../etc/initramfs-tools/conf.d/modules.conf | 1 + .../etc/initramfs-tools/hooks/storage | 24 +++++++++++++++++++ .../initramfs-tools/conf.d/compression.conf | 2 ++ .../etc/initramfs-tools/conf.d/modules.conf | 1 + .../etc/initramfs-tools/hooks/storage | 24 +++++++++++++++++++ 7 files changed, 55 insertions(+) create mode 100644 2nd-stage-files/post-2nd-stage-files/etc/initramfs-tools/conf.d/modules.conf create mode 100644 2nd-stage-files/pre-2nd-stage-files-arm64/etc/initramfs-tools/conf.d/compression.conf create mode 100644 2nd-stage-files/pre-2nd-stage-files-arm64/etc/initramfs-tools/conf.d/modules.conf create mode 100755 2nd-stage-files/pre-2nd-stage-files-arm64/etc/initramfs-tools/hooks/storage create mode 100644 2nd-stage-files/pre-2nd-stage-files-armhf/etc/initramfs-tools/conf.d/compression.conf create mode 100644 2nd-stage-files/pre-2nd-stage-files-armhf/etc/initramfs-tools/conf.d/modules.conf create mode 100755 2nd-stage-files/pre-2nd-stage-files-armhf/etc/initramfs-tools/hooks/storage diff --git a/2nd-stage-files/post-2nd-stage-files/etc/initramfs-tools/conf.d/modules.conf b/2nd-stage-files/post-2nd-stage-files/etc/initramfs-tools/conf.d/modules.conf new file mode 100644 index 0000000..a47d7de --- /dev/null +++ b/2nd-stage-files/post-2nd-stage-files/etc/initramfs-tools/conf.d/modules.conf @@ -0,0 +1 @@ +MODULES=dep diff --git a/2nd-stage-files/pre-2nd-stage-files-arm64/etc/initramfs-tools/conf.d/compression.conf b/2nd-stage-files/pre-2nd-stage-files-arm64/etc/initramfs-tools/conf.d/compression.conf new file mode 100644 index 0000000..1793c9a --- /dev/null +++ b/2nd-stage-files/pre-2nd-stage-files-arm64/etc/initramfs-tools/conf.d/compression.conf @@ -0,0 +1,2 @@ +COMPRESS=gzip +COMPRESSLEVEL=9 diff --git a/2nd-stage-files/pre-2nd-stage-files-arm64/etc/initramfs-tools/conf.d/modules.conf b/2nd-stage-files/pre-2nd-stage-files-arm64/etc/initramfs-tools/conf.d/modules.conf new file mode 100644 index 0000000..a724f56 --- /dev/null +++ b/2nd-stage-files/pre-2nd-stage-files-arm64/etc/initramfs-tools/conf.d/modules.conf @@ -0,0 +1 @@ +MODULES=list diff --git a/2nd-stage-files/pre-2nd-stage-files-arm64/etc/initramfs-tools/hooks/storage b/2nd-stage-files/pre-2nd-stage-files-arm64/etc/initramfs-tools/hooks/storage new file mode 100755 index 0000000..e7e7ffe --- /dev/null +++ b/2nd-stage-files/pre-2nd-stage-files-arm64/etc/initramfs-tools/hooks/storage @@ -0,0 +1,24 @@ +#!/bin/sh -e + +PREREQ="" + +# Output pre-requisites +prereqs() +{ + echo "$PREREQ" +} + +case "$1" in + prereqs) + prereqs + exit 0 + ;; +esac + +. /usr/share/initramfs-tools/hook-functions + +auto_add_modules base +auto_add_modules block +auto_add_modules mmc + +manual_add_modules ext4 diff --git a/2nd-stage-files/pre-2nd-stage-files-armhf/etc/initramfs-tools/conf.d/compression.conf b/2nd-stage-files/pre-2nd-stage-files-armhf/etc/initramfs-tools/conf.d/compression.conf new file mode 100644 index 0000000..1793c9a --- /dev/null +++ b/2nd-stage-files/pre-2nd-stage-files-armhf/etc/initramfs-tools/conf.d/compression.conf @@ -0,0 +1,2 @@ +COMPRESS=gzip +COMPRESSLEVEL=9 diff --git a/2nd-stage-files/pre-2nd-stage-files-armhf/etc/initramfs-tools/conf.d/modules.conf b/2nd-stage-files/pre-2nd-stage-files-armhf/etc/initramfs-tools/conf.d/modules.conf new file mode 100644 index 0000000..a724f56 --- /dev/null +++ b/2nd-stage-files/pre-2nd-stage-files-armhf/etc/initramfs-tools/conf.d/modules.conf @@ -0,0 +1 @@ +MODULES=list diff --git a/2nd-stage-files/pre-2nd-stage-files-armhf/etc/initramfs-tools/hooks/storage b/2nd-stage-files/pre-2nd-stage-files-armhf/etc/initramfs-tools/hooks/storage new file mode 100755 index 0000000..e7e7ffe --- /dev/null +++ b/2nd-stage-files/pre-2nd-stage-files-armhf/etc/initramfs-tools/hooks/storage @@ -0,0 +1,24 @@ +#!/bin/sh -e + +PREREQ="" + +# Output pre-requisites +prereqs() +{ + echo "$PREREQ" +} + +case "$1" in + prereqs) + prereqs + exit 0 + ;; +esac + +. /usr/share/initramfs-tools/hook-functions + +auto_add_modules base +auto_add_modules block +auto_add_modules mmc + +manual_add_modules ext4