From 5aea95129ecc7f36cfd04ed10b67bb4b3dde5c71 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 25 Jun 2026 22:43:47 +0300 Subject: [PATCH] BuildSystem: Allow building compressed initrd Building with BANAN_INITRD=2 will now compress using gzip! --- README.md | 2 +- script/image.sh | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bde65ecd..5627e116 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ To change the bootloader you can set environment variable BANAN\_BOOTLOADER; sup To run with UEFI set environment variable BANAN\_UEFI\_BOOT=1. You will also have to set OVMF\_PATH to the correct OVMF (default */usr/share/ovmf/x64/OVMF.fd*). -To build an image with no physical root filesystem, but an initrd set environment variable BANAN\_INITRD=1. This can be used when testing on hardware with unsupported USB controller. +To build an image with no physical root filesystem, but an initrd set environment variable BANAN\_INITRD=1. This can be used when testing on hardware with unsupported USB controller. If BANAN\_INITRD is set to a value larger than 1, initrd will be gzip compressed. If you have corrupted your disk image or want to create new one, you can either manually delete *build/banan-os.img* and build system will automatically create you a new one or you can run the following command. ```sh diff --git a/script/image.sh b/script/image.sh index c1443f39..e58b2e3f 100755 --- a/script/image.sh +++ b/script/image.sh @@ -39,11 +39,14 @@ fi if sudo mount "$ROOT_PARTITION" "$MOUNT_DIR"; then if (($BANAN_INITRD)); then - fakeroot -i "$BANAN_FAKEROOT" tar -C "$BANAN_SYSROOT" -cf "$BANAN_SYSROOT.initrd" . + INITRD_FILE="$BANAN_BUILD_DIR/banan-os.initrd" + (($BANAN_INITRD > 1)) && COMPRESS_FLAGS='-z' || COMPRESS_FLAGS='' + + fakeroot -i "$BANAN_FAKEROOT" tar -C "$BANAN_SYSROOT" --exclude='./boot' $COMPRESS_FLAGS -cf "$INITRD_FILE" . sudo mkdir -p "$MOUNT_DIR/boot" - sudo cp "$BANAN_BUILD_DIR/kernel/banan-os.kernel" "$MOUNT_DIR/boot/banan-os.kernel" - sudo mv "$BANAN_SYSROOT.initrd" "$MOUNT_DIR/boot/banan-os.initrd" + sudo strip -o "$MOUNT_DIR/boot/banan-os.kernel" --strip-unneeded "$BANAN_BUILD_DIR/kernel/banan-os.kernel" + sudo cp "$INITRD_FILE" "$MOUNT_DIR/boot/banan-os.initrd" else sudo rsync -rulHpt "$BANAN_SYSROOT/" "$MOUNT_DIR"