Skip to content

Add Zstandard support to MagiskBoot - #10261

Draft
Andrey-Pepper wants to merge 1 commit into
topjohnwu:masterfrom
Andrey-Pepper:add-zstd-magiskboot
Draft

Andrey-Pepper wants to merge 1 commit into
topjohnwu:masterfrom
Andrey-Pepper:add-zstd-magiskboot

Conversation

@Andrey-Pepper

Copy link
Copy Markdown

Summary

Add Zstandard (ZSTD) compression and decompression support to MagiskBoot.

Changes

  • Add the zstd crate dependency.
  • Add FileFormat::ZSTD.
  • Detect ZSTD streams using their magic bytes.
  • Add ZSTD encoder and decoder support.
  • Include ZSTD in the supported compression formats.
  • Add unit tests for format detection, parsing, properties, and compression/decompression roundtrip.

Testing

  • Successfully built MagiskBoot for all four Android ABIs.
  • Verified ZSTD compression/decompression roundtrip.
  • Successfully unpacked a boot image containing a ZSTD-compressed ramdisk.
  • All 4 unit tests passed.
  • Successfully built the Magisk APK and tested installation on a Samsung Galaxy A13.

🤖 Generated with ChatGPT

@vvb2060

vvb2060 commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Which OEM uses zstd? Please upload the img file for test.

@Andrey-Pepper

Copy link
Copy Markdown
Author

Which OEM uses zstd? Please upload the img file.

I was using RestlessOS 17 on my Samsung Galaxy A13 (SM-A135F, Exynos 850).

The boot image included KernelSU (GKI 2), but it didn't work on my device. I decided to switch to Magisk, but the boot image patching process failed.

After investigating the boot image, I found that the ramdisk was compressed using Zstandard (ZSTD), which was not supported by MagiskBoot at the time.

I added ZSTD support to my local MagiskBoot build, rebuilt Magisk, and everything worked correctly. I was able to patch the boot image and install Magisk successfully.

Here is the RestlessOS 17 ROM package I used (originally shared on 4PDA):
https://drive.google.com/file/d/1hEd8LSQe-tTATtWJnmXAmtrJUVZvd2Ym/view?usp=drive_link

RestlessOS 17 boot.img:
https://drive.google.com/file/d/161NkF-WoEiKFr1zyGAj4imNJ1Dx9vIA6/view?usp=sharing

I hope this helps verify the issue and the implementation.

@osm0sis

osm0sis commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

It fails to build.

@vvb2060
vvb2060 marked this pull request as draft November 18, 2026 17:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants