# put stock boot.img into /sdcard/boot.img
# get sha1
adb shell
su
SHA1=$(cat $(magisk --path)/.magisk/config | grep SHA1 | cut -d '=' -f 2)
# repack boot.img.gz
gzip -9f /sdcard/boot-stock.img
# restore backup
mkdir /data/magisk_backup_${SHA1}
mv /sdcard/boot-stock.img.gz /data/magisk_backup_${SHA1}/boot.img.gz
chmod -R 755 /data/magisk_backup_${SHA1}
chown -R root.root /data/magisk_backup_${SHA1}
Last active
December 26, 2025 04:50
-
-
Save pexcn/71d7d242c5e805d9346d2dc9db17fb90 to your computer and use it in GitHub Desktop.
bro I don't have SD card. Can I done with internal storage??
This script helped me. Thank you!
bro I don't have SD card. Can I done with internal storage??
"/sdcard" is your internal storage
If you already have stock boot.img file in /sdcard you can do the do following and let Magisk do the backup
cd /data/adb/magisk cp /sdcard/boot.img stock_boot.img ./magiskboot cleanup . ./util_functions.sh run_migrations
This is the answer.
The last line run_migrations doesn't work though. But it doesn't matter - at this point you are already able to run the "Restore Images"
Edit: the run_migrations shows an error msg - Unable to find preinit dir. But behind the scene everything should work fine now
This is the answer.
The last linerun_migrationsdoesn't work though. But it doesn't matter - at this point you are already able to run the "Restore Images"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My Pixel 4a 5G aka bramble runs LineageOS for microG. I've installed Magisk via patched boot.img. Therefore Magisk ought to have backuped stock boot.image already on that occasion. But it did not. Additionally I let Magisk patch stock boot.img several times after installation, in the hope it would then create a backup, which it did never.
The magisk_install.log from last installation is this:
I wonder, if these not permitted operations are causing this failing to backup the stock boot.img and what I might do about it.