Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Magisk leftovers #5338

Open
ewillner opened this issue Feb 14, 2022 · 11 comments
Open

Clean up Magisk leftovers #5338

ewillner opened this issue Feb 14, 2022 · 11 comments

Comments

@ewillner
Copy link

Is your feature request related to a problem? Please describe.
Magisk leaves a bunch of backup folders/files after patching (and does not clean them up). The folders are below /data and have the format /magisk_backup_???? - where ??? are a sequence of "random" characters. The folders contain a file "boot.img.gz". Per:
https://forum.xda-developers.com/t/magisk-general-support-discussion.3432382/post-86418905 and
https://forum.xda-developers.com/t/magisk-general-support-discussion.3432382/post-86418905
These folders can be deleted, except for the one with the most recent date.

Describe the solution you'd like
Add a feature within SD (possibly systemcleaner) - that would delete all folders named /data/magisk_backup_* with the exception of the one with the latest date.

Describe alternatives you've considered
I have done the deletions manually, but clearly that is not the greatest user experience. SD does this type of thing so well, and it would be great if this could be added.

Additional context
Add any other context or screenshots about the feature request here.

@d4rken
Copy link
Member

d4rken commented Feb 19, 2022

How do I get Magisk to create those? I don't have them on my rooted devices, do I need a specific Magisk version?

@ewillner
Copy link
Author

ewillner commented Feb 20, 2022 via email

@dragonGod97677
Copy link
Collaborator

dragonGod97677 commented Mar 10, 2022

How do I get Magisk to create those? I don't have them on my rooted devices, do I need a specific Magisk version?

@d4rken

Lets say you have a unrooted phone and you rooted it in this way

Flash custom recovery>rename magisk.apk to zip via recovery>flash the zip

Now magisk is doing is creating a folder on /data named magisk_backup_??? And makes 2 copies of unpatched stock boot image in that folder

The first copy, magisk will not touch it because it will be the backup.

Magisk will touch the second copy, it will get patched, written to boot partition and delete the second copy and everything is done

The ??? Is just a random string or a md5 hash of a previous boot image whether its unpatched boot image or boot image with previous version of magisk

Then the next few days, there was a notification, magisk update, you installed the update directly, via app, it will do(what i think of), create a new folder, like the first time you flash the zip, then makes 2 copies the current boot image you have to the newly created folder

then patches the second copy then directly flashes it to boot partition and deletes the second copy.

Problem, whether installing an magisk update via app or recovery, doesn't check for previous old backups that can be deleted

And i think it doesn't need a specific version unless there were changes how magisk behaves on updating

@ewillner
Copy link
Author

This description makes sense.

If I understand correctly, you are summarizing, providing a (great!) technical description and acknowledging the issue.

Is there anything else that you may need from me? It seems that the "needs info/repro" tag is still assigned.

Thank you again.

@dragonGod97677
Copy link
Collaborator

dragonGod97677 commented Mar 11, 2022

There is a new magisk update now, ill update today and check if these 2 folder became 3, then magisk it still doesn't do anything on previous boot image backups

Also @ewillner , darken will just tag you when he needs more info from you and he is probably busy and checking before removing "needs info/repro" issue label

Screenshot_20220311-123154

@dragonGod97677
Copy link
Collaborator

I just updated magisk via direct installation, it doesn't make new backup of boot image and the old 2 folders i have still there.

Maybe magisk doesn't make backups of boot image anymore when you update directly

@ewillner
Copy link
Author

@dragonGod97677 - thank you for your clarification and your testing.

I also updated magisk (to v24.3) via direct installation and did not get any extra folders created.

Then I went through the process that I would use to flash an updated version of my ROM:

  1. Flash the ROM
  2. Flash TWRP (I like that recovery over the Lineage)
  3. Reboot into recovery
  4. Flash Magisk (a copy of magisk.apk renamed to magisk.zip)

With this sequence, an additional folder was still created.

@dragonGod97677
Copy link
Collaborator

@dragonGod97677 - thank you for your clarification and your testing.

I also updated magisk (to v24.3) via direct installation and did not get any extra folders created.

Then I went through the process that I would use to flash an updated version of my ROM:

  1. Flash the ROM
  2. Flash TWRP (I like that recovery over the Lineage)
  3. Reboot into recovery
  4. Flash Magisk (a copy of magisk.apk renamed to magisk.zip)

With this sequence, an additional folder was still created.

So... Now we get that magisk only backups boot image when a fresh install via recovery or install update via recovery

@dragonGod97677
Copy link
Collaborator

dragonGod97677 commented Mar 11, 2022

Also your welcome :D

@Nitrovenom
Copy link

How do I get Magisk to create those? I don't have them on my rooted devices, do I need a specific Magisk version?

Magisk creates those when flashed through recovery

@TheRealMystic
Copy link

Yes, that's true. I also see 2 folders. I rooted mine by flashing Magisk on Android 11 via TWRP. Then upgraded to Android 12, but had to use the 'Install to inactive slot' route to keep root, since TWRP is not supported on Android 12 in my device. I guess that's why I also see 2 folders.

@d4rken d4rken modified the milestones: Next tasks, SD Maid 2/SE Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants