What should I delete from /data to prevent started encryption on a ROM that doesn't support it? - Android Q&A, Help & Troubleshooting

TL;DR: somewhere in /data, it is written that Android should encrypt some partitions including /data on next reboot, but my ROM doesn't support decrypting. I managed to make a backup of /data with twrp, but when I remove encryption, restore the backup, and reboot, the ROM tries to encrypt (which it only does if I restore my data backup so somewhere on /data it sees that it was rebooting to encrypt), so what should I delete from /data after restoring it to cancel the planned encryption?
(Clarification: I don't think this is encryption enforced, because I can format and boot to Android without encryption happening, it's only if I restore my backed up data that encryption happens on boot.)
Some background:
So I made the mistake of starting the Android full disk encryption on a custom ROM (non official AOKP 7.1.2, J120F/DS, SC8830) and since I installed the ROM a year ago I forgot that it doesn't support encryption and clicked encrypt.
After the encryption, it got stuck on a black screen, adb working but /data, /dev and something else I forgot what were showing as "tmpfs", and to make matters worse, twrp for j120f was too old and doesn't support encryption, so what I did was use the tool from Hovatek and the working twrp 3.0.2 to make a working twrp 3.2.1 for my phone (sc8830), and it worked, and twrp decrypted it and I made a backup with adb backup --twrp data. I removed encryption by formatting and restored it and checked that it's no longer encrypted by rebooting to twrp.
Now the issue is, rebooting to the system again starts the encryption (coz the ROM encrypts but can't decrypt) so somewhere in /data it's saved that it has rebooted to encrypt. I tried deleting these:
/data/system/gatekeeper.password.key
/data/system/gatekeeper.patern.key
/data/system/locksettings.db
/data/system/locksettings.db-shm
/data/system/locksettings.db-wal
but still the encryption started after reboot. So it must be saved in some other file that is included in my backup. Can you please tell me where so I can delete it and restore my backup? Thank you very much!

Related

Nandroid backup problem

Today I decided to upgrade the cyanogenmod software of my girlfriend's phone. I did a android backup before doing it and I have it both on my SD card and on the phone. The upgrade went wrong (dont'know why i was having many crashes of some apps) so i decided to restore the android backup. I have tarp recovery and i'm having two problems. The first one is when I select MD5 check: it's written MD5 failed to match on... maybe because I followed the guide about creating an MD5 blank file ( I was having problems in matching MD5). When I uncheck the MD5 check box, the backup starts and it seems it works, but when I press reboot the system it says NO OS INSTALLED. I need some help please I've tried for two hours fixing it.
What partitions did you backup and try to restore? Sounds like /system or /boot didn't backup or restore properly. You could try to reinstall the original rom she was on and then do just a /data restore and see if that works. Other than that, either another rom or back to stock are the main options. What was going wrong on the new rom? Did you try to upgrade by dirty flashing - as in not wiping /data? Sometimes it also helps to format /system too when upgrading the rom to make sure there's nothing leftover. Also, getting the correct Gapps are important for everything to run correctly.
PS: I've been having some issues with backups in TWRP on my phone as well and wasn't able to restore /data and if I just choose to restore just boot and /system then it would at least boot backup and be usable. I'm not sure if this is a similar issue to yours or just phone specific.

Will TWRP make a full NAND backup? Any pitfalls / limitations?

A long time ago while installing TWRP & rooting the tablet using the DirtyCOW exploit, I lost my entire user partition due to it being encrypted.
Currently am trying to switch my root from SuperSU to Magisk Systemless.
I don't want the possibility to lose my user data or /system modifications if anything goes wrong. I made a lot of edits here and there to tweak the tablet to my liking, and would hate to have everything lost.
To preserve its current state, I want be create a full TWRP backup.
I would like to make sure, that the TWRP backup is a full NAND backup that will let me revert to the current state no matter what I do to the tablet. Eg, it acts like a true system snapshot.
- My /data partition is showing up as 0bytes (Unknown Errror 150)
- I read that a /system backup is worthless due to dm-verity. For a working backup you need a block exact system-image backup.
Anyone have a guide on how to create a non worthless backup>? I am on TWRP 3.0.2-0 (ancient I know)

How to restore a /data partition on Android Q from tarball after factory reset?

Hi! So, I have a newer Android 10 device with no TWRP support. I think my question is not model specific, so I'm posting generally, but if it matters, it's a OnePlus 7T Pro, bootloader unlocked of course.
Anyway, since there's no good custom recoveries for Android Q (none that I know of that can decrypt /data), I was trying to be safe and using a hacked (adb enabled) stock recovery to make backups from the command line. I have a nice tarball created in recovery mode with "tar cvf - /data/". It looks like it was made properly, I can unpack the files on back onto the device in recovery mode, and it's not corrupt or anything.
The problem is that naively trying to restore it back to my /data partition (e.g. tar xvf) after a wipe causes two problems:
1) after rebooting to recovery, the /data partition just looks encrypted again. If it was working properly, stock recovery can decrypt /data
2) normal system boot just bootloops.
If anyone has tried manually saving and restoring /data from a tarball, I'd appreciate any tips on getting it to work.
My best guess is that the ext4 encryption keys are the culprit - since after a factory reset the device creates new encryption keys, I think I need to figure out how to restore 99% of my backup without overwriting the fresh encryption keys that were created after wiping. I think I need to combine the new encryption keys with the other files in my tarball backup. If I can get past that, I might have to worry about things like SELinux xattrs as well, but one thing at a time.
If any experienced Android hackers know how filesystem encryption works in Android 10, I would appreciate a map of which files should not be overwritten. For example, I'm thinking I should probably avoid restoring some of these files:
Code:
/data/unencrypted/key
/data/unencrypted/key/encrypted_key
/data/unencrypted/key/keymaster_key_blob
/data/misc/vold/user_keys
/data/misc/vold/user_keys/de/0/keymaster_key_blob
/data/misc/vold/user_keys/de/0/encrypted_key
/data/misc/vold/user_keys/ce/0/current/keymaster_key_blob
/data/misc/vold/user_keys/ce/0/current/encrypted_key
/data/misc/systemkeys
/data/misc/keystore
/data/misc/keychain
/data/system/recoverablekeystore.db
[edit] spoke too soon
I ended up doing something janky and wrote a little shell script to repack the files from /data/data and /data/app into files that Titanium Backup could understand. I also figured out how to restore my SMS messages from /data/user_de. That was enough to recover the things I cared most about.
Still begs the question of what's the best method of doing backup and restores of /data on Android 10 when you don't have custom recovery but you do have Magisk, root, and stock recovery with adb. I want to keep hacking and playing with this phone so gotta figure something out.
I like Titanium Backup, have used it for many years, but the maintainance hasn't really kept up with Android development, theres a lot of gotchas like it hangs trying to restore multi APK packages. I still want to figure out something more seamless like a nandroid backup solution even if its from the command line. At least until TWRP eventually supports Android 10.
try backing up data partition in a external storage live usb or sd card
DrWowe said:
I ended up doing something janky and wrote a little shell script to repack the files from /data/data and /data/app into files that Titanium Backup could understand. I also figured out how to restore my SMS messages from /data/user_de. That was enough to recover the things I cared most about.
Still begs the question of what's the best method of doing backup and restores of /data on Android 10 when you don't have custom recovery but you do have Magisk, root, and stock recovery with adb. I want to keep hacking and playing with this phone so gotta figure something out.
I like Titanium Backup, have used it for many years, but the maintainance hasn't really kept up with Android development, theres a lot of gotchas like it hangs trying to restore multi APK packages. I still want to figure out something more seamless like a nandroid backup solution even if its from the command line. At least until TWRP eventually supports Android 10.
Click to expand...
Click to collapse
try backing up data partition in a external storage live usb or sd card, first you for encryption, then restore from external source after formatting phone storage

(solved) Locked out of phone after data restore.

Today I reflashed my e7 using LMSA.
I then completed the setup wizard except i didn't enter a password because this was only for the purpose of testing to see if the device worked as it should.
I then proceeded to restore a backup of my data partition using MtkClient.
After this my device boots but does not accept the correct password or my adb authorisation.
I assume this has to do with the decryption keys being different due to the reset done by LMSA.
If someone could point me to the partition that contains the decryption keys I could restore it from a previous backup.
Any help would be appreciated.
Moto e7.
Android 10 File based Encryption.
Edit:
Solved.
All I had to do was set the phone up with the same password as the data backup then restore the data backup and it was able to decrypt.
Hallelujah!

How to do TWRP Backup with system_ext and encryption ?

I always just backup every partition and restore them all but when i boot into android i get the security error and it tells me to delete all my data. What am i doing wrong ?

Categories

Resources