Skip to content

Instantly share code, notes, and snippets.

@24HOURSMEDIA
Last active May 14, 2021 07:45

Revisions

  1. 24HOURSMEDIA renamed this gist May 14, 2021. 1 changed file with 0 additions and 0 deletions.
  2. 24HOURSMEDIA revised this gist May 14, 2021. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion 999_decompress_rpi_kernel
    Original file line number Diff line number Diff line change
    @@ -1 +1,4 @@
    DPkg::Post-Invoke {"/bin/bash /boot/firmware/auto_decompress_kernel"; };
    #!/bin/bash -e

    sudo echo 'DPkg::Post-Invoke {"/bin/bash /boot/firmware/auto_decompress_kernel"; };' > /etc/apt/apt.conf.d/999_decompress_rpi_kernel
    sudo chmod +x /etc/apt/apt.conf.d/999_decompress_rpi_kernel
  3. 24HOURSMEDIA revised this gist May 14, 2021. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion auto_decompress_kernel
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    #!/bin/bash -e

    #Set Variables
    # Put this script in the root of the boot partition (i.e. system-boot) and chmod it with +x
    # Set Variables
    BTPATH=/boot/firmware
    CKPATH=$BTPATH/vmlinuz
    DKPATH=$BTPATH/vmlinux
  4. 24HOURSMEDIA revised this gist May 1, 2021. No changes.
  5. 24HOURSMEDIA revised this gist May 1, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions 999_decompress_rpi_kernel
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    DPkg::Post-Invoke {"/bin/bash /boot/firmware/auto_decompress_kernel"; };
  6. 24HOURSMEDIA created this gist May 1, 2021.
    47 changes: 47 additions & 0 deletions auto_decompress_kernel
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    #!/bin/bash -e

    #Set Variables
    BTPATH=/boot/firmware
    CKPATH=$BTPATH/vmlinuz
    DKPATH=$BTPATH/vmlinux

    #Check if compression needs to be done.
    if [ -e $BTPATH/check.md5 ]; then
    if md5sum --status --ignore-missing -c $BTPATH/check.md5; then
    echo -e "\e[32mFiles have not changed, Decompression not needed\e[0m"
    exit 0
    else echo -e "\e[31mHash failed, kernel will be compressed\e[0m"
    fi
    fi

    #Backup the old decompressed kernel
    mv -f $DKPATH $DKPATH.bak

    if [ ! $? == 0 ]; then
    echo -e "\e[31mDECOMPRESSED KERNEL BACKUP FAILED!\e[0m"
    exit 1
    else echo -e "\e[32mDecompressed kernel backup was successful\e[0m"
    fi

    #Decompress the new kernel
    echo "Decompressing kernel: "$CKPATH".............."

    zcat $CKPATH > $DKPATH

    if [ ! $? == 0 ]; then
    echo -e "\e[31mKERNEL FAILED TO DECOMPRESS!\e[0m"
    exit 1
    else
    echo -e "\e[32mKernel Decompressed Succesfully\e[0m"
    fi

    #Hash the new kernel for checking
    md5sum $CKPATH $DKPATH > $BTPATH/check.md5

    if [ ! $? == 0 ]; then
    echo -e "\e[31mMD5 GENERATION FAILED!\e[0m"
    else echo -e "\e[32mMD5 generated Succesfully\e[0m"
    fi

    #Exit
    exit 0