Tuesday 2 August 2016

LZMA compression tool

Hey , this is a small tool -you can call it patch - to compress kernel / recovery ramdisk .

Why this tool ?
Simply some devices have little space for kernel / recovery like samsung galaxy star which has about 10MBs for kernel/recovery .

How to use :
  • You must first activate LZMA support for ramdisks in kernel Go to your kernel config file then change this

    Code:


    # CONFIG_RD_LZMA is not set

    TO

    Code:


    CONFIG_RD_LZMA=y


  • Clone the tool under device/vendor_name/device_name.

  • Add those line to your BoardConfig.mk file .

    Code:


    # LZMA compression for recovery's & kernel ramdisk....
    BOARD_CUSTOM_BOOTIMG_MK := device/vendor_name/device_name/custombootimg.mk
    BOARD_CANT_BUILD_RECOVERY_FROM_BOOT_PATCH := true



  • Enjoy .


Note :
  • This tools is used while you building any ROM/Kernel/Recovery from source .

  • This tool should work with any device .

  • LZMA compression takes more time to decompress than GZIP but When I tested it didn't take more than 1 or 2 more seconds to decompress .
    You won't be able to decompress boot.img or recovery.img using boot-repacker or unpack tool for linux as you will get an error because those tools won't be able to decompress ramdisks for recovery or kernel -boot-repacker only gives you kernel zImage- and If you want to edit anything in ramdisk you will need to build it again from source !!!

  • This tool derived from

    http://review.cyanogenmod.org/#/c/96227/
    http://review.cyanogenmod.org/#/c/118533/


Results using this tool :
Before :
Kernel ramdisk : 1.1 MB (1,117,760 bytes) .
recovery ramdisk : 4.2 MB (4,158,392 bytes) .
Total kernel.img : 9.1 MB (9,111,552 bytes) .
Total recovery.img : 12.2 MB (12,152,832 bytes) .


After :
Kernel ramdisk : 579.3 kB (579,257 bytes) .
recovery ramdisk : 2.7 MB (2,736,844 bytes) .
Total kernel.img : 8.6 MB (8,572,928 bytes) .
Total recovery.img : 10.7 MB (10,731,520 bytes) .



Something to discuss :
Maybe you find that these compress is not enough to save up the space or you maybe find this is very suitable for you , In my case it was useful in some aspects and not in others .
I tried to use LZMA compression for kernel zImage it self and it was pretty good (8 MBs to 2.9 MBs) but the problem that the kernel wasn't loaded so It themes that the bootloader of my device hate LZMA compression or anything else I didn't figure it out so If you find anyway to run and support LZMA compression for kernel please kindly let me know .

Download :
LZMA compression tool

Credit :
Andreas Blaesius
Dan Pasanen
LehKeda (ME :D)

No comments:

Post a Comment