Last active
December 22, 2025 15:47
-
-
Save veygax/809062e895c17ae4112200f7efec4168 to your computer and use it in GitHub Desktop.
bash script to extract compressed super.img's
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| XZ="meta-quest_eureka_userdebug_v71_super.img.xz" | |
| SUPER="super.img" | |
| TMP="temp_partitions" | |
| OUT="extracted_fs_userdebug" | |
| [ ! -f $SUPER ] && xz -dkc "$XZ" > $SUPER | |
| mkdir -p "$TMP" "$OUT" | |
| # unsparse super.img | |
| simg2img $SUPER $SUPER.raw 2>/dev/null || cp $SUPER $SUPER.raw | |
| # unpack the raw super image into temp dir | |
| lpunpack $SUPER.raw "$TMP" && rm $SUPER.raw | |
| # sort images to ensure 'system' is processed first as 'system' is the root | |
| IMG_LIST=$(ls $TMP/*_a.img | grep "system_a.img") | |
| IMG_LIST="$IMG_LIST $(ls $TMP/*_a.img | grep -v "system_a.img")" | |
| for img in $IMG_LIST; do | |
| name=$(basename "$img" _a.img) | |
| # system maps to root, others map to their respective subdirectories | |
| if [ "$name" == "system" ]; then | |
| dest="$OUT" | |
| else | |
| dest="$OUT/$name" | |
| # wipe existing mount point to ensure clean extraction | |
| rm -rf "$dest" && mkdir -p "$dest" | |
| fi | |
| # attempt to unsparse all partition images | |
| simg2img "$img" "$img.raw" 2>/dev/null && mv "$img.raw" "$img" | |
| # try debugfs (for things such as 'system_ext'), fallback to 7z for everything else | |
| debugfs -R "rdump / \"$dest\"" "$img" 2>/dev/null || 7z x "$img" -o"$dest" -aoa >/dev/null | |
| done | |
| rm -rf "$TMP" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment