Decrypting "Internal Storage" aka "/data/media/0" aka "/sdcard" - Redmi K20 / Xiaomi Mi 9T Questions & Answers

Hi
I was trying to flash xiaomi.eu (xiaomi.eu_multi_HMK20MI9T_V12.5.2.0.RFJCNXM_v12-11) custom rom to my Mi 9T device via TWRP recovery
I booted into recovery then I noticed TWRP isn't asking for a password for decryption
So dumb me ignored it and "Advance Wiped" all partitions except "Internal Memory" and flashed the rom from "USB OTG"
then problems started to appear
first the rom didn't boot and was stuck in a boot loop
so I wiped and reflashed the original "miui_DAVINCIGlobal_V12.1.4.0.RFJMIXM_e0ac13ed89_11.0" rom via TWRP from "USB OTG" to be able to back up my files and do a proper format/decrypt
but the internal storage is now still encrypted and cannot be accessed
I tried twrp decrypt command with all combinations of passwords pins pattern numbers that I used since first bought the phone but none of them worked
I know I should have backed up my files
Now I want to know how can decrypt /data/media/0 aka /sdcard aka Internal Memory and get my files
like mounting it in windows through some adb and other software and decrypting with known key combinations and passwords
or through twrp or whatever that maybe work
I really can't afford to lose my data AGAIN
yes, that wasn't my first time!!!!!
I promise if this gets right I devote the rest my life to the open-source community
excuse me for my bad English.

When flashing a custom ROM, or going back from, you HAVE to Format (not just Wipe) Data
(And you don't need to wipe System because new ROM will overwrite it anyway, and you better never wipe Persist and so)
Obviously, you must backup your photos, data, etc, before switching the ROM
Data on Internal memory is encrypted, and not by your unlock pin (unlock pin just serves to verify and read the key).
New ROM reinitializes the encryption key
Hence, AFAIK, you cannot decrypt anymore because you don't know the encryption key that was used for data on your Internal memory

Seems you have similar problem as I have

zgfg said:
When flashing a custom ROM, or going back from, you HAVE to Format (not just Wipe) Data
(And you don't need to wipe System because new ROM will overwrite it anyway, and you better never wipe Persist and so)
Obviously, you must backup your photos, data, etc, before switching the ROM
Data on Internal memory is encrypted, and not by your unlock pin (unlock pin just serves to verify and read the key).
New ROM reinitializes the encryption key
Hence, AFAIK, you cannot decrypt anymore because you don't know the encryption key that was used for data on your Internal memory
Click to expand...
Click to collapse
ok
a question
why the twrp was not asking for decryption in first place?

ehsan1326 said:
ok
a question
why the twrp was not asking for decryption in first place?
Click to expand...
Click to collapse
No idea - ask devs of your custom ROM how they implement encryption and what is the proper way to install the ROM

Related

Phone encrypted after flashing rom, cannot decrypt using TWRP.

As the title states, I flashed the lastest Cataclysm (stable) and ElementalX kernel(also TWRP asked me that SuperSU wasn't present and to flash it so I did, that might've messed it up), phone booted up fine and set my fingerprint password and everything. I decided to reboot my phone and the phone encrypted itself and now the ROM is force closing and I can't do anything. It asks for a password every time the recovery starts up (I tried default_password, no go) and TWRP won't let me decrypt.
So my question is, is there a way to decrypt without erasing userdata? Would really like to keep my internal storage. I have lots of important pictures and files.
Jimlarck said:
As the title states, I flashed the lastest Cataclysm (stable) and ElementalX kernel(also TWRP asked me that SuperSU wasn't present and to flash it so I did, that might've messed it up), phone booted up fine and set my fingerprint password and everything. I decided to reboot my phone and the phone encrypted itself and now the ROM is force closing and I can't do anything. It asks for a password every time the recovery starts up (I tried default_password, no go) and TWRP won't let me decrypt.
So my question is, is there a way to decrypt without erasing userdata? Would really like to keep my internal storage. I have lots of important pictures and files.
Click to expand...
Click to collapse
Transfer the files to your computer and decrypt properly, either via fastboot line command, or one of the toolkits that will do the fastboot command lines for you...there is no way around nuking your internal memory if you want to decrypt...it's that simple.
Sent from my Nexus 6P, #WhiteUIsMustDie, #EndDarkAppOppression
micmars said:
Transfer the files to your computer and decrypt properly, either via fastboot line command, or one of the toolkits that will do the fastboot command lines for you...there is no way around nuking your internal memory if you want to decrypt...it's that simple.
Sent from my Nexus 6P, #WhiteUIsMustDie, #EndDarkAppOppression
Click to expand...
Click to collapse
Damn, thought there might be a magic guru way of decrypted your storage. Why did it encrypt in the first place? Can ROMs encrypt devices when flashed?
Also, I thought it being encrypted prevented me from moving any of the files out of my phone?
Jimlarck said:
Damn, thought there might be a magic guru way of decrypted your storage. Why did it encrypt in the first place? Can ROMs encrypt devices when flashed?
Also, I thought it being encrypted prevented me from moving any of the files out of my phone?
Click to expand...
Click to collapse
Nope, unfortunately, no magic way around it...
As to whether roms can or cannot encrypt, it is the kernel that either forces encryption or allows for you to remain in your current state (either encrypted or decrypted)...you'd never want a kernel to force decryption, as that rom would erase your entire internal memory.
As to moving files from your phone, here's a very simple way of looking at it that is not too far from the reality of things under the hood...
When you have an encrypted device, and you have a password set, once you enter your password, you can move files freely from your device to your computer, etc, without issue, and they'll be decrypted.
If you are encrypted, do not know your password, and try to move those same files, they'll be encrypted and unreadable to anyone. To many, that's a excellent feature...it's comforting to know that any unsuspecting thief can't get access to your stuff...and it also allows you time to remotely wipe your device using Android Device Manager from your computer.
Finally, as to how it works, it is my understanding that the device stores your password on the same partition from where it decrypts files prior to opening them, making for a very efficient and effective security measure.
I hope this helps.
Sent from my Nexus 6P, #WhiteUIsMustDie, #EndDarkAppOppression
FYI:
- twrp backup data
- copy /sdcard to pc
- fastboot format userdata
- copy from pc to /sdcard
- restore data in twrp
are the needed steps to decrypt without losing any data.
Delete

Axon 7 randomly stopped booting

Hi there, I have an Axon 7 with LineageOS that was working like a charm until I rebooted it today. It was in the normal lineage OS boot animation with the blue circle moving from right to left, except it never stopped. Now after trying a few more times, it just keeps playing the animation except the phone will vibrate slightly every several seconds. The phone is encrypted but that hasn't been a problem. When I reboot to TWRP, it says Unable to mount storage.
I tried wiping Cache and Dalvik / ART Cache, but this didn't help. Finally, I do have a backup from 7-20-2017 but I'd rather not have to go back to that...
Any recommendations?
Chrono7x said:
Hi there, I have an Axon 7 with LineageOS that was working like a charm until I rebooted it today. It was in the normal lineage OS boot animation with the blue circle moving from right to left, except it never stopped. Now after trying a few more times, it just keeps playing the animation except the phone will vibrate slightly every several seconds. The phone is encrypted but that hasn't been a problem. When I reboot to TWRP, it says Unable to mount storage.
I tried wiping Cache and Dalvik / ART Cache, but this didn't help. Finally, I do have a backup from 7-20-2017 but I'd rather not have to go back to that...
Any recommendations?
Click to expand...
Click to collapse
So you can't see the internal storage from TWRP? I'm guessing encryption actually plays a part here. Formatting data is probably the best course of action, though you should flash magisk or superSu if you do, to get rid of encryption. But you obviously lose everything that's on the internal storage.
Maybe make a system and boot backup and clean flash Lineage. Like, wipe system and caches, then flash the bootloader, modem, LOS and whatever else you flash
Choose an username... said:
So you can't see the internal storage from TWRP? I'm guessing encryption actually plays a part here. Formatting data is probably the best course of action, though you should flash magisk or superSu if you do, to get rid of encryption. But you obviously lose everything that's on the internal storage.
Maybe make a system and boot backup and clean flash Lineage. Like, wipe system and caches, then flash the bootloader, modem, LOS and whatever else you flash
Click to expand...
Click to collapse
Is it easier to just use the backup I have currently? If so, what are the steps necessary for that (sorry for newb questions, haven't messed with it in a while)
EDIT: Also, TWRP claims decryption is successful when it is loading up.
Chrono7x said:
Is it easier to just use the backup I have currently? If so, what are the steps necessary for that (sorry for newb questions, haven't messed with it in a while)
EDIT: Also, TWRP claims decryption is successful when it is loading up.
Click to expand...
Click to collapse
Again. Can you see the internal storage?
Don't restore the backup. Your problem is basically either on /system (clean flash of the ROM will do) or on /data (complete format of data is needed). So try the non destructive one first
Choose an username... said:
Again. Can you see the internal storage?
Don't restore the backup. Your problem is basically either on /system (clean flash of the ROM will do) or on /data (complete format of data is needed). So try the non destructive one first
Click to expand...
Click to collapse
I don't see any storage folder. So if I want to install the latest LOS and frankly just start from scratch, can I follow the guide here https://wiki.lineageos.org/devices/axon7/install#installing-lineageos-from-recovery starting from "Installing LineageOS from recovery"? Will I still need to install something to wipe the encryption?
Chrono7x said:
I don't see any storage folder. So if I want to install the latest LOS and frankly just start from scratch, can I follow the guide here https://wiki.lineageos.org/devices/axon7/install#installing-lineageos-from-recovery starting from "Installing LineageOS from recovery"? Will I still need to install something to wipe the encryption?
Click to expand...
Click to collapse
What? No... That's for normal phones. How did you manage to install LOS without knowing that you need the univ. bootloader and modem?
So, you can't access the internal storage via the file manager on TWRP i'm guessing.
Wipe - Format data, after that flash the Universal bootloader, modem, LOS, Magisk, GApps. Magisk takes care of dm-verity and disables encryption. Don't try to uninstall it though or your internal storage will get encrypted as soon as you do. But if you want to change ROMs you can just fpash it before booting and it won't ger encrypted.

(Yet Another) Question on Encryption

So, I've been reading ad nauseum on this topic with regards to flashing new ROMs on my 6t and getting locked out due to decryption.
Among other threads and places across the interweb, I've read all of these:
https://forum.xda-developers.com/search/forum/8259?query=Encryption
During my travels I've discovered that the s**t doesn't really hit the fan until "data" is wiped via TWRP. I see that the recommend process for flashing new ROMs goes like this:
Boot on twrp
Flash ROM
Flash twrp installer
Reboot to twrp
Factory reset
Reboot to system
Am I understanding this correctly that if I transpose steps 4 and 5, then I shall plan on losing all of my data, but if I reboot from TWRP (right back into TWRP) before step 5 (aka data wipe), I shouldn't loose my data?
Assuming that is correct, does it matter if I leave a lock screen password enabled before rebooting to TWRP from the soon-to-be replaced ROM? I ask this because removing the lock screen password did not seem to reduce my chances of encountering permananly encrypted data.
Thanks!
notorious.dds said:
So, I've been reading ad nauseum on this topic with regards to flashing new ROMs on my 6t and getting locked out due to decryption.
Among other threads and places across the interweb, I've read all of these:
https://forum.xda-developers.com/search/forum/8259?query=Encryption
During my travels I've discovered that the s**t doesn't really hit the fan until "data" is wiped via TWRP. I see that the recommend process for flashing new ROMs goes like this:
Boot on twrp
Flash ROM
Flash twrp installer
Reboot to twrp
Factory reset
Reboot to system
Am I understanding this correctly that if I transpose steps 4 and 5, then I shall plan on losing all of my data, but if I reboot from TWRP (right back into TWRP) before step 5 (aka data wipe), I shouldn't loose my data?
Assuming that is correct, does it matter if I leave a lock screen password enabled before rebooting to TWRP from the soon-to-be replaced ROM? I ask this because removing the lock screen password did not seem to reduce my chances of encountering permananly encrypted data.
Thanks!
Click to expand...
Click to collapse
Yes. For the love of god. Someone please clear up how we can flash on the go. I don't always have access to a computer with Adb/fastboot.
Every time I try to switch roms, upon rebooting to TWRP, my folders encrypt. Then I have to format data and voila, no fricking ROM to flash and I'm stuck
idkwhothatis123 said:
Yes. For the love of god. Someone please clear up how we can flash on the go. I don't always have access to a computer with Adb/fastboot.
Every time I try to switch roms, upon rebooting to TWRP, my folders encrypt. Then I have to format data and voila, no fricking ROM to flash and I'm stuck
Click to expand...
Click to collapse
Yeah A/B partition are a nuisance when it comes to flashing. I'd recommend you to do a clean flash of the ROM. Follow these steps.
1. Download the Latest Stable OOS from OnePlus's Website. Download the ROM ZIP of your Choice as well as the latest TWRP Installer. Transfer these to your phone and also copy them to a Laptop as you might have to Format Data.
2. Now Reboot to Recovery and flash OOS ZIP and TWRP Installer. Let it finish. Once it's done Reboot to Recovery from Within TWRP.
3. Again flash OOS and TWRP Installer. If for some reason your folders are messed up (as you posted in the image earlier) just go to Wipe and Format Data. And transfer the OOS and TWRP Installer to Internal and Flash them. Let it finish.
4. Once that's done, now again Reboot to Recovery and now flash ROM and TWRP Installer. After that's done, again Reboot to Recovery.
5. Again, flash ROM and TWRP Installer. Once done, Reboot to Recovery.
6. Now flash Gapps of your Choice. Stock are Recommend while anything above Nano will work. AROMA won't work. Once Gapps are flashed now go to Wipe and do a Factory Reset (Swipe to Factory Reset). Once that's Done, hit Reboot System and wait for the ROM to Load.
7. After the Initial Setup, Reboot to Recovery and flash Magisk and Custom Kernel if you want.
Personally I Format Data after flashing Gapps to get a "clean install". But that's not necessary. Also if you want to flash ROMs often I'd suggest investing in Swift Backup. It's an excellent app for Backups and can Backup almost Anything. Hope this helps.
This is what I do. Occasionally I get the Encrypted Folders but if followed correctly all is smooth. I can flash any ROM without Encryption. Except maybe stock OOS.
Thanks Mannan.
However, what I'm really looking for is someone to explain the following:
1. Which action or actions is it that triggers the phone to be encypted without a way to decrypt when flashing a new rom? My suspicion is that if the phone was encrypted while having been boot from slot A, then wiping data while in slot A results in data loss. By extension, rebooting into slot B and then wiping data allows slot B to now hold the encryption key. I'm sure this theory has got some errors, but it's the best I can come up with having no intrinsic knowledge on the topic.
2. Are there any means of mitigating data loss should the phone become encrypted? I.e. If possible, can I back up data (minus /data/media) and then restore that when I can't get access to /data/media?
With regards to question #1, I developed my "suspicion" after lossing ambition to test it. When I get my ambition back to fight this issue, I'll try again. I'm just getting sick of transfering 25+ gigs of data via adb every time the data gets encrypted and I can't get it decrypted.
notorious.dds said:
Thanks Mannan.
However, what I'm really looking for is someone to explain the following:
1. Which action or actions is it that triggers the phone to be encypted without a way to decrypt when flashing a new rom? My suspicion is that if the phone was encrypted while having been boot from slot A, then wiping data while in slot A results in data loss. By extension, rebooting into slot B and then wiping data allows slot B to now hold the encryption key. I'm sure this theory has got some errors, but it's the best I can come up with having no intrinsic knowledge on the topic.
2. Are there any means of mitigating data loss should the phone become encrypted? I.e. If possible, can I back up data (minus /data/media) and then restore that when I can't get access to /data/media?
With regards to question #1, I developed my "suspicion" after lossing ambition to test it. When I get my ambition back to fight this issue, I'll try again. I'm just getting sick of transfering 25+ gigs of data via adb every time the data encryption kicks in.
Click to expand...
Click to collapse
You're not that far off, actually. And while I'm no developer I suspect that Encryption kicks in when
a). You flash stock OOS. No matter what ROM you are on, when you flash OOS it's possible you can get encrypted. I'm not sure about this but if a developer could confirm that'd be great. This one time, I flashed OOS Stable while on Beta and it Encrypted my Storage. So I had to retransfer with a computer to flash it the required two times. So basically avoid flashing OOS when on a Custom ROM. Even when switching ROMs.
b). Just as you said, when you Wipe Data within TWRP and then Reboot to TWRP it also Encrypts the Device. So I usually Wipe Data after flashing ROM & Gapps. Otherwise if you Wipe Data after flashing ROM it will Encrypt you.
And to answer that last Question the app I personally use is called Swift Backup. It's an amazing app and although it costs $5.49 it can Backup Apps and Data. It can also backup the Files in Android/obb. Give it a go.
Mannan Qamar said:
You're not that far off, actually. And while I'm no developer I suspect that Encryption kicks in when
a). You flash stock OOS. No matter what ROM you are on, when you flash OOS it's possible you can get encrypted. I'm not sure about this but if a developer could confirm that'd be great. This one time, I flashed OOS Stable while on Beta and it Encrypted my Storage. So I had to retransfer with a computer to flash it the required two times. So basically avoid flashing OOS when on a Custom ROM. Even when switching ROMs.
Click to expand...
Click to collapse
I've been fiddling around with OOS and The Pixel Experience (aka TPE) ROM. I've yet to need to flash OOS in order to loose my ability to decrypt. Flashing TPE screws everything up quite nicely as well. That said, I have gotten into the situation where TWRP (booted from either slot) has got everything encrypted. However, in one case, I was able to get the data back by recreating the boot_a partition as it existed before I wiped data. I think there may be something to be learned here. However, subsequent attempts to use this method have not been successful. In other words, I'm not sure what I actually learned.
Mannan Qamar said:
And to answer that last Question the app I personally use is called Swift Backup. It's an amazing app and although it costs $5.49 it can Backup Apps and Data. It can also backup the Files in Android/obb. Give it a go.
Click to expand...
Click to collapse
I'm still using Titanium Backup (paid version as well). It works quite well and I'm happy with it. That said, it's still a much bigger pain in the butt to restore vs performing a nandroid restore of the data. It's apples and oranges though. In order for the nandroid to provide any real value, you pretty much have to do right before need it... unless you never do anything on your phone. It also only works with the ROM from which it was created... obviously. Since my current nandroid backup of /data is > 22 gb, its fairly cumbersome.
notorious.dds said:
I've been fiddling around with OOS and The Pixel Experience (aka TPE) ROM. I've yet to need to flash OOS in order to loose my ability to decrypt. Flashing TPE screws everything up quite nicely as well. That said, I have gotten into the situation where TWRP (booted from either slot) has got everything encrypted. However, in one case, I was able to get the data back by recreating the boot_a partition as it existed before I wiped data. I think there may be something to be learned here. However, subsequent attempts to use this method have not been successful. In other words, I'm not sure what I actually learned.
I'm still using Titanium Backup (paid version as well). It works quite well and I'm happy with it. That said, it's still a much bigger pain in the butt to restore vs performing a nandroid restore of the data. It's apples and oranges though. In order for the nandroid to provide any real value, you pretty much have to do right before need it... unless you never do anything on your phone. It also only works with the ROM from which it was created... obviously. Since my current nandroid backup of /data is > 22 gb, its fairly cumbersome.
Click to expand...
Click to collapse
I dunno if it will work but when you get Encrypted try booting the TWRP image. Maybe that'll work.
Doesn't this problem occur with backups and restore from twrp as well?.... This A/B stuff I'm not used to but I'll keep reading and hopefully something in my brain will kick in lol...
Mannan Qamar said:
I dunno if it will work but when you get Encrypted try booting the TWRP image. Maybe that'll work.
Click to expand...
Click to collapse
Yeah, that I defintitely tried. No dice. However, I just backed up everthing and I'm about to start blowing the thing up with ROM flashes. Consider it a stress test. I'll report back.
What I've got so far...
Coming from OOS 9.0.14 running on slot B with a lock screen pattern enabled, I boot into TWRP on slot B.
I then flashed The Pixel Experiance ROM via it's .zip file. (The flash is then applied to slot A because it goes to the inactive slot).
Flashed the TWRP install .zip
Changed active slot to A
Reboot to recovery (aka TWRP) ... now in slot A.
wiped data (minus storage)
Flashed magisk
Reboot system
This got me into the new ROM with data intact. However, when rebooting to recovery (still slot A), it would ask for a pattern but yet wouldn't accept the pattern to decrypt. Rebooting back into Pixel Experience the data was decrypted. So, even the data would decrypt when booted into system, I could no longer get to the data from within TWRP. I then changed the lock pattern from within Pixel Experience and reboot to TWRP, it still couldn't decrypt the data. Rebooting back to system succeeded in that it actually boot, but I could no longer unlock the phone (stuck on "phone is starting"). My presumption at this point was that Pixel Experience could no longer decrypt the data.
I then:
Reboot to TWRP (slot A still)
Flashed OOS
Flashed TWRP
Set active slot to B
Reboot to recovery (aka TWRP)
wiped data (minus storage)
reboot to system
At this point OOS failed to boot and I was returned to TWRP. Data was still not able to be decrypted. I then did a factory reset plus wiped storage (aka data, dalvik, and internal storage) and tried to boot to system... still failed and sent me back to TWRP. This time, although data was empty, it was decrypted. I tried to reboot system again. It failed again and sent me back to TWRP.
So, at this point , I've wiped data and internal storage but I cannot get stock OOS to boot. So, I reboot to bootloader and executed:
Code:
fastboot -w
My understanding is that this should do the same this as performing a factory reset from within TWRP. However, rebooting to system succeeded this time.
So, the new questions are:
1. How is it that I can decrypt data when booted into Pixel Experience on slot A, but I cannot decrypt the data via TWRP?
2. If I removed the lock screen pattern from OOS before flashing PixelExperience, would I have been able to decrypt the data in both the ROM and within TWRP?
3. Why is factory resetting via fastboot effective when doing so in TWRP is not?
notorious.dds said:
What I've got so far...
Coming from OOS 9.0.14 running on slot B with a lock screen pattern enabled, I boot into TWRP on slot B.
I then flashed The Pixel Experiance ROM via it's .zip file. (The flash is then applied to slot A because it goes to the inactive slot).
Flashed the TWRP install .zip
Changed active slot to A
Reboot to recovery (aka TWRP) ... now in slot A.
wiped data (minus storage)
Flashed magisk
Reboot system
This got me into the new ROM with data intact. However, when rebooting to recovery (still slot A), it would ask for a pattern but yet wouldn't accept the pattern to decrypt. Rebooting back into Pixel Experience the data was decrypted. So, even the data would decrypt when booted into system, I could no longer get to the data from within TWRP. I then changed the lock pattern from within Pixel Experience and reboot to TWRP, it still couldn't decrypt the data. Rebooting back to system succeeded in that it actually boot, but I could no longer unlock the phone (stuck on "phone is starting"). My presumption at this point was that Pixel Experience could no longer decrypt the data.
I then:
Reboot to TWRP (slot A still)
Flashed OOS
Flashed TWRP
Set active slot to B
Reboot to recovery (aka TWRP)
wiped data (minus storage)
reboot to system
At this point OOS failed to boot and I was returned to TWRP. Data was still not able to be decrypted. I then did a factory reset plus wiped storage (aka data, dalvik, and internal storage) and tried to boot to system... still failed and sent me back to TWRP. This time, although data was empty, it was decrypted. I tried to reboot system again. It failed again and sent me back to TWRP.
So, at this point , I've wiped data and internal storage but I cannot get stock OOS to boot. So, I reboot to bootloader and executed:
My understanding is that this should do the same this as performing a factory reset from within TWRP. However, rebooting to system succeeded this time.
So, the new questions are:
1. How is it that I can decrypt data when booted into Pixel Experience on slot A, but I cannot decrypt the data via TWRP?
2. If I removed the lock screen pattern from OOS before flashing PixelExperience, would I have been able to decrypt the data in both the ROM and within TWRP?
3. Why is factory resetting via fastboot effective when doing so in TWRP is not?
Click to expand...
Click to collapse
Well starting from the way you flashed the ROM, the rule of thumb is that you NEVER manually change slots. Now since you are on stock follow the instructions I posted earlier to flash PE or any other ROM for that matter. I think when you manually set the slot it somehow messed up Decryption. Next, after flashing OOS from TWRP when you are on a Custom ROM, you must always Format Data. The command you ran via Fastboot (fastboot -w) does just that.
So I just flashed Bootleggers from Stock OpenBeta 11. These are the steps I followed. I was successfully able to flash and was able to keep my Data intact. These are the steps I followed.
Starting from OpenBeta 11 I flashed ROM (Bootleggers) and then TWRP Installer. Then go to Reboot and Select Recovery. Once in Recovery, again flash ROM and TWRP Installer. Once done, reboot to Recovery. Flash Gapps and then go to Wipe and do a Swipe to Fa Tory Reset. This will Delete all your Data except Internal Storage. This is a necessary step when flashing a ROM. Once done, reboot to System. After this I was able to boot up Successfully with my Internal Storage as it was before flashing. After that I restored my backup. Everything is working and I can enter and Decrypt TWRP without error.
This thread should be pined as a guide because instalation notes in ROM threads are so basic.
A couple of things come to mind reading this thread in reference to encryption
1) if security patches dont match on A/B, it seems to trigger a lockout with encryption. i may be wrong.
2) if internal storage isnt wiped, i.e.-if you use the "factory reset' option in twrp, your data is still there and that in itself post-flash can trigger encryption error as the data is still there.
I think about it like this, despite it being A/B partitions, the data is like a middle layer that isnt individualized to one partition or the other. so a trigger/failure for secure boot encrypts it all.
kitcostantino said:
A couple of things come to mind reading this thread in reference to encryption
1) if security patches dont match on A/B, it seems to trigger a lockout with encryption. i may be wrong.
2) if internal storage isnt wiped, i.e.-if you use the "factory reset' option in twrp, your data is still there and that in itself post-flash can trigger encryption error as the data is still there.
I think about it like this, despite it being A/B partitions, the data is like a middle layer that isnt individualized to one partition or the other. so a trigger/failure for secure boot encrypts it all.
Click to expand...
Click to collapse
I'm pretty sure, that if you flash anything with a security patch earlier than the one you're currently using your data will get encrypted.
Which is why it happens with going back to OOS from custom, because they're always late with security patches compared to custom roms.
The hardest thing for.me coming from an A only device (Axon 7) has been learning order of operations. as long as one flashes rom followed by twrp and then a reboot into recovery, followed by installing magisk, things usually go okay. Going from aosp to aosp went okay, but like you said moving from OOS to AOSP or vice versa always yielded encryption lock. maybe we could make a merged security patch or something of the sort to bridge the gap. im no dev, so im sure someone who knows more than i can tell us why that wouldnt work. it would be really cool for One Plus to gain a better foothold in custom OS before the majority of crack flashers and devs swear off. Dont get me wrong, OOS is amazing and i feel with the inherent features, is superior to any other stock rom, but android is all about choice.
i really and truly wish someone would make a version of TWRP that had a dual boot set up vs A/B. I have had devices (looking at you, Droid Bionic) that never had proper root/bl unlock and had amazing rom communities bc of safestrap/dual boot/etc. i am more than willing to give up internal storage space to duplicate/clone /data and anything else that is on both systems. i also wish recovery had its own partition again, but that one is beyond our control at this point as it resides in boot now.
Maybe its conceivable. Who knows.
I have no issues. I don't lose anything when I flash ROMs. I boot to twrp, factory reset(not wipe storage), flash ROM, flash twrp installer....boot ROM, reboot twrp, flash gapps, custom kernel. Then I factory reset again (not wipe storage) and then install magisk..done....no issues. It will fail boot once and then boot fine because of this process but only after you do this. So if you reboot later you are fine...I keep all my stuff
First off, I want to thank all of you who contributed to this thread. I'm defintely gaining a better understanding of some of the pitfalls associated with A/B devices and encryption. Thanks!
Mannan Qamar said:
Well starting from the way you flashed the ROM, the rule of thumb is that you NEVER manually change slots. Now since you are on stock follow the instructions I posted earlier to flash PE or any other ROM for that matter. I think when you manually set the slot it somehow messed up Decryption.
Click to expand...
Click to collapse
So, my understand is that flashing a new ROM from within TWRP flashes it to the inactive slot. Therefore, my assumptions as to the reasoning behind rebooting from TWRP back into TWRP before wiping data were that:
Any modifiations made to the boot partition intended to affect the new ROM need to be made to the boot partition that shares the same slot as that of the new ROM, and
Wiping data while booted into image of TWRP which shares the same slot as the new ROM has some magical effect on preserving the ability to decrypt data vs wiping data while booted into the image of TWRP that resides in the slot of the ROM to be replaced.
It is these assumptions (combined with my execution of the basic recipe failing to prevent encryption lock-out) which led me to manually changing slots. I will say this... after flashing PE and TWRP.zip from within TWRP on slot B, simply rebooting to recovery brought me right back to TWRP on slot B. If PE is now on slot A, how does installing magisk, etc. do me any good while in slot B? Also, are my assumptions misguided as to the "why" rebooting to TWRP before installing magisk, wiping data, etc is necessary?
Mannan Qamar said:
Next, after flashing OOS from TWRP when you are on a Custom ROM, you must always Format Data. The command you ran via Fastboot (fastboot -w) does just that.
Click to expand...
Click to collapse
Lightbulb status: on
Thanks!
kitcostantino said:
If security patches dont match on A/B, it seems to trigger a lockout with encryption. i may be wrong.
Click to expand...
Click to collapse
Is this why in Mannan Qamar's earlier post he appears to be flashing the new ROM to BOTH slots before trying to boot into system?
ebproject said:
I'm pretty sure, that if you flash anything with a security patch earlier than the one you're currently using your data will get encrypted.
Which is why it happens with going back to OOS from custom, because they're always late with security patches compared to custom roms.
Click to expand...
Click to collapse
I'm assuming that flashing OOS to BOTH slots as is mentioned earlier with regards to flashing a custom ROM won't help when going back to OOS given the old vs new issue. Has anyone verified that yet?
It's my understanding that the sure security patch is applied to the system partition, correct? Is part of that patch included in boot, or no?
jamescable said:
I have no issues. I don't lose anything when I flash ROMs. I boot to twrp, factory reset(not wipe storage), flash ROM, flash twrp installer....boot ROM, reboot twrp, flash gapps, custom kernel. Then I factory reset again (not wipe storage) and then install magisk..done....no issues. It will fail boot once and then boot fine because of this process but only after you do this. So if you reboot later you are fine...I keep all my stuff
Click to expand...
Click to collapse
I notice that the FIRST thing you do is "factory reset". That's definitely not standard with the install threads I've read. Hmmmmm, interesting.
Also, why do you boot the ROM before flashing gapps, and kernel? It seems unnecessary since you're just factory resetting again. I'm sure I'm missing something on this one.
notorious.dds said:
I notice that the FIRST thing you do is "factory reset". That's definitely not standard with the install threads I've read. Hmmmmm, interesting.
Also, why do you boot the ROM before flashing gapps, and kernel? It seems unnecessary since you're just factory resetting again. I'm sure I'm missing something on this one.
Click to expand...
Click to collapse
Booting to ROM solved the encryption issues
idkwhothatis123 said:
Yes. For the love of god. Someone please clear up how we can flash on the go. I don't always have access to a computer with Adb/fastboot.
Every time I try to switch roms, upon rebooting to TWRP, my folders encrypt. Then I have to format data and voila, no fricking ROM to flash and I'm stuck
Click to expand...
Click to collapse
If you stuck on encrypted storage ever, reboot to system and after you see the setup screen, reboot to recovery again. Voila, your storage is decrypted now.
It happened to me all the time when I flash OOS and this way I am able to decrypt my internal storage.

[HELP] Data encrypted unable to decrypt with TWRP

My device bootlooped after new update, it seemed fine, i update it normally last week and it worked fine. today i did a TWRP backup of all of the partitions and then rebooted and it went into bootloop. I was able to flash all the partitions again with the flash-all-partitions.bat and got it out of fastboot. Now i can boot TWRP with an .img again.
The problem is that my data is all encrypted, like it mounts but its all in ramdom folders with ramdom names, and TWRP is not asking for the code to decrypt it. I dont know how to decrypt the data. How can i decrypt it? ( i know the code as it was my password).
Thank you
I would say format data and re-flash rom via twrp, that should remove encryption (but you loose all of your data) and you should be able to normally boot.
marahlad said:
I would say format data and re-flash rom via twrp, that should remove encryption (but you loose all of your data) and you should be able to normally boot.
Click to expand...
Click to collapse
yes but the problem is im trying to preserve data, it was pretty sudden i need to acces my 2fa backups and other important files, thats why i havent formatted everything and reflashed. bc im trying to look for solutions whre i can decrypt my data and get the important stuff out of there.

Installation lineageos

Hi guys,i have a mi9t with bl unlocked and would change from miui to lineage,but my device is crypted,i can flash twrp,do wipe,install and reboot o could be dangerous with the encryption and how to disable if i can,t flash lineage,thank
(sorry for my bad english)
sbnnn said:
Hi guys,i have a mi9t with bl unlocked and would change from miui to lineage,but my device is crypted,i can flash twrp,do wipe,install and reboot o could be dangerous with the encryption and how to disable if i can,t flash lineage,thank
(sorry for my bad english)
Click to expand...
Click to collapse
General procedure when switching ROMs (you can double-check, guides can be found elswhere, not specifically for LOS and generally for Xiaomi phones)
- Backup as much as you can, by various methods
- Install the latest official TWRP
- Boot to TWRP, enter your Android unlock pin to be able to see Internal memory (to be able to flash the ROM zip file from Internal memory)
- Flash the ROM (do not Wipe anything)
- F O R M A T (not Wipe - different options in TWRP, formatting does more than wiping, that's what you need for the proper encryption for the new ROM) DATA partition (it will also wipe Internal memory - that's why you need to backup first)
- reboot to the new ROM
zgfg said:
General procedure when switching ROMs (you can double-check, guides can be found elswhere, not specifically for LOS and generally for Xiaomi phones)
- Backup as much as you can, by various methods
- Install the latest official TWRP
- Boot to TWRP, enter your Android unlock pin to be able to see Internal memory (to be able to flash the ROM zip file from Internal memory)
- Flash the ROM (do not Wipe anything)
- F O R M A T (not Wipe - different options in TWRP, formatting does more than wiping, that's what you need for the proper encryption for the new ROM) DATA partition (it will also wipe Internal memory - that's why you need to backup first)
- reboot to the new ROM
Click to expand...
Click to collapse
I am in twrp without pin,but it Is removed after restart,so can i flash a rom with MIUI encrypted(only format)?
sbnnn said:
I am in twrp without pin,but it Is removed after restart,so can i flash a rom with MIUI encrypted(only format)
Click to expand...
Click to collapse
If you don't use the pin on Android, TWRP should not ask you.
If you use pattern, it will ask you for the pattern
But you need that only to be able to navigate to the zip file you want to flash.
You can put the zip file to USB -OTG or also to external SD card you will put to the second SIM slot, then TWRP does not need the pin, it will not need to read Internal memory
After you flash and when you Format Data (it will also reformat Internal memory), it's all over
When you reboot to the new ROM, the new ROM will create it's own, new encryption (but to be able to do that, you had to Format Data before rebooting to that new ROM)
Some ppl do even this way:
- first they Format Data
- then they sidelload new ROM zip file from PC (they cannot flash from Inernal memory because they have already formatted Data and therefore lost everything from Internal nemory)
- then they reboot to the new ROM
Ie, it is important that you do both flashing the ROM and formatting Data from TWRP before you reboot, the order is not important
However, for me it's easier to flash from Download folder than sideloading, that's why I suggested you to Format after flashing
Once you reboot to the new ROM, it will establish its new encryption, it will ask you to setup your new unlock pin/pattern (or nothing if you prefer your phone to stay unsecure)
---
Hence, if you will be sideloading or flashing from USB-OTG or external SD card, who cares for your unlock pin while you are entering TWRP before flashing
---
Wiping Data delete files and folders only, but the old encryption remains (and new ROM does not handle it)
Formatting prepares Data (with Internal memory) for nthe new ROM to make its own, new encryption
You know what is different between formatting hard disk/usb stick/SD card from just wiping files.
Formatting creates new file system, wiping leaves the old file system but only removes files and folders
Btw, some people wipe only (or do not even wipe because they 'think' they can save their stuff while switching the ROM)
Then they report problems with the new ROM (and neither the new ROM, nor TWRP can no more read Internal memory, hence they loose their stuff anyway)
Then they cry for help, and they finally learn and accept they have to Format Data - they do it (it doesn't affect the ROM they had previously flashed to System partition - different partition hence not affected by later formatting Data)
After they finally format Data (two days or a week later after flashing the new ROM), they reboot and they can finally then to properly setup.the new ROM
zgfg said:
Btw, some people wipe only (or do not even wipe because they 'think' they can save their stuff while switching the ROM)
Then they report problems with the new ROM (and neither the new ROM, nor TWRP can no more read Internal memory, hence they loose their stuff anyway)
Then they cry for help, and they finally learn and accept they have to Format Data - they do it (it doesn't affect the ROM they had previously flashed to System partition - different partition hence not affected by later formatting Data)
After they finally format Data (two days or a week later after flashing the new ROM), they reboot and they can finally then to properly setup.the new ROM
Click to expand...
Click to collapse
I have installed lineageos without problem,but when i try to flash potatoasosp with android 12 result an error,It would baseband v12.1.4(like),how to now?
Thank for tour support
sbnnn said:
I have installed lineageos without problem,but when i try to flash potatoasosp with android 12 result an error,It would baseband v12.1.4(like),how to now?
Thank for tour support
Click to expand...
Click to collapse
No idea, I don't use those ROMs (I prefer MIUI not stock but Xiaomi.eu)
Flash firmware - it's all described in 1st post. You need specific firmware for ROM to work

Categories

Resources