[KERNEL][RECOVERY][LOS15.1] F2FS upstreamed Kernel + TWRP for Lineage 15.1 - Lenovo P2 ROMs, Kernels, Recoveries, & Other Devel

WARNING: I am not responsible if you brick your device or lose any data. I personally heavely tested these releases myself and have not encountered any problems.
These are built on official sources and nothing more should be broken but remember to always make backups before installing any mods, kernels etc.!
You should read everything I wrote in this thread before taking any steps unless you know exactly what are doing.
About:
Okay, so I was tired of almost not usable Magisk on official builds because of outdated Moto F2FS implementation, so I built new LOS15.1 kernel and Treble-compatible TWRP with newer version of it for myself and I want to share this with you.
You may ask why I did it and what does it change, so here's the list of features:
This combo may be solution for smooth transition from 15.1 --> 16 without losing data (Without this you will need to reformat your /data partition before flashing when the day of 16 comes - confirmed by Mike). I cannot say 100% that it give you this ability but I'm pretty sure it will!
This Kernel and TWRP applies to LineageOS 15.1, all LOS15.1-based ROMs (like RRemix) and all Treble GSI's.
F2FS loopback fix module is not needed anymore, you can directly install modules from Magisk Manager app.
Magisk modules are persistent now. They will never disappear, even when cache is cleared.
Magisk hide settings are persistent now. They will not reset after reboot.
You can now use systemless hosts properly (No ads and SafetyNet is still passing!).
Filesystem R/W speeds may and should be slightly better (I haven't tested this myself so feel free to do before-after benchmark comparisions).
Don't need to start from zero. You can restore your /data backup after formatting device and it will work just fine.
TWRP is updated to version 3.2.3-0 so it may fix OTA's on "enter pin to boot" encrypted devices.
In TWRP there's written "Lineage" next to it's version to avoid confusion, especially for newbs (Lineage because everyone's talking about LOS TWRP and it's also built on Lineage source)
"Format Data" button in "Wipe" screen is temporarily removed until I/we find fix to make it work. This feature is still broken and causing bootloops (Like on TWRP from LOS Wiki). You still need to use official one for decryption.
That's all I think. I will edit this thread If missed something.
Instructions:
* This instruction applies to new and existing LOS-based ROMs users *
* This tutorial I wrote for someone may be useful if you need help with bootloader mode(fastboot) *
Important: If you don't care about porting your /data to newer F2FS (not talking about Internal data) and willing to start from "zero" then you just should typical LOS installation steps + changing kernel (Steps 1 - 8 and 14 eventually if you're going to restore some pictures or something)
1. Do /data partition and/or Internal Storage backups if you didn't already. Pull them to your computer or SD card.
2. Flash TWRP 3.2.3-0 Lineage build (lineagetwrp.img) from the download section using method you want (fastboot one is recommended).
3. Flash latest official build of LOS15.1 (If you have it already then you can skip this step).
4. Flash bootimage (f2fs_boot.img): Install > Install Image > f2fs_boot.img and check "Boot"
5. Download latest official TWRP from HERE
6. Boot to bootloader mode (fastboot) and use this command "fastboot boot [OFFICIAL_TWRP_IMAGE.img]" to boot into official TWRP without flashing it.
7. When in official TWRP: Wipe > Format Data > type "yes". If it fails then reboot to bootloader mode (Main menu > Reboot > Bootloader) and boot it once again as in point 3 (It happens very often).
8. If formatting went fine then go to: Reboot > Recovery to boot to recovery flashed before. After it boots just make sure that it says "3.2.3-0 Lineage" on top bar like in attachment screnshot
9. Wipe > Advanced Wipe > check "Data" > Repair or Change File System > Change File System > F2FS (This step is not really necessary but it confirms that everything is set up if no errors was throwed here).
10. Reboot to recovery and put your TWRP /data backup on your Internal Storage via PC - Skip if on SD card.
11. Restore your TWRP backup.
12. Don't exit yet if you haven't restored from SD card. There's a little bug(?) where your data from Internal Storage will stay in /data/media directory but MTP will switch to /data/media/0/ after first boot so you will be not able to see that data via PC. Make sure you've deleted these files before rebooting to system. You can do this after first start too but these files will extend encypting time at least twice.
13. Finally you can reboot. In case you were using any lockscreen when doing a backup you should check THIS
14. You can put back your internal storage data right when ROM successfully booted.
Download:
DOWNLOAD - 12.01.2019
Troubleshooting:
If you encounter any problems in any of these steps you will probably need to start from step 6.
Still not able to do this or messed something up very badly so u can't enter TWRP? Try entering bootloader mode and type "fastboot erase userdata", then proceed to step 6.
Remember: After doing an OTA you will need to flash "f2fs_boot.img" once again before booting into system. Else you will end in constant reboots until you do this. Kernel will be updated when some changes will be pushed into it (not often)
Any support for this will be probably instantly dropped after first stable enough release of LineageOS 16.
Have Fun!​
All thanks goes to @mikeioannina for commiting to kuntao sources which I used here.
Kernel source
Recovery source​

Thx, I was looking for this.
---------- Post added at 10:11 AM ---------- Previous post was at 09:20 AM ----------
I reread the whole article again and better to wait for lineage os 16 and fixes. I am fine with ext4 now. No need to mess with twrp and bootloops

Well, the most complicated flashing orgy so far...

Why making another kernel for putting just 1 commit that fixes f2fs? Recovery was needed because for treble we are still using 3.2.2-0, but kernel is useless, @mikeioannina could merge that commit in official lineage kernel.

mahmutpekkara said:
Thx, I was looking for this.
---------- Post added at 10:11 AM ---------- Previous post was at 09:20 AM ----------
I reread the whole article again and better to wait for lineage os 16 and fixes. I am fine with ext4 now. No need to mess with twrp and bootloops
Click to expand...
Click to collapse
There's almost no changes in that kernel compared to stock. The same for TWRP. The real difference between this procedure and re-installing LOS15.1 is installing the kernel file. Resetting lockscreen settings (because your pins will not work) was always the case when restorong nandroid backup.
If you're on ext4 then just stay on it. Not worth doing it in your case

RayDeemer said:
Well, the most complicated flashing orgy so far...
Click to expand...
Click to collapse
It's not that complicated even if it looks like that. It's very detailed, step by step comparing to typical flashing instructions. I did this because I know that a lot of users from this forum have problems even with simple things. Like I said before: the only difference between this and reinstalling ROM with restoring /data partition is flashing boot.img. Not my fault that this treble TWRP formatting feature is broken and nandroid backups are breaking login when PIN is set.

matteo0026 said:
Why making another kernel for putting just 1 commit that fixes f2fs? Recovery was needed because for treble we are still using 3.2.2-0, but kernel is useless, @mikeioannina could merge that commit in official lineage kernel.
Click to expand...
Click to collapse
This will not gonna happen and that's why I compiled it myself. He reverted this change before it came live and I just readded it (https://github.com/LineageOS/androi...it/48c639c3581eb04693ae0771d8e85ce1151550b4).
You will probably find his post around page 50 of LOS thread about that.
He said that he will be not push this change to build since it will break LOS14 -> LOS15.1 transition when doing an OTA (user data will be corrupted if I remember correctly).
If you wondered why this tutorial is long and "complicated" like people said before then as you can see it turns out that data transition could be done with simply doing nandroid backup and then restoring it. These step are 90% of this tutorial due to bugs which are in lineage TWRP and "bugs" because that TWRP is backing up ROM with lockscreen settings which are breaking every time when restoring from backup. Also removing backup data step is necessary because these files will slow down encryption and will be not placed in /sdcard so people will forget about it probably and wonder what is eating so much space.
EDIT: I forgot to add that Mike refused my opinion about this but at the end you will still need to format your data anyway when going from 15.1 to 16. This kernel with TWRP may be solution for smooth transition to 16.

Kielbek said:
This will not gonna happen and that's why I compiled it myself. He reverted this change before it came live and I just readded it (https://github.com/LineageOS/androi...it/48c639c3581eb04693ae0771d8e85ce1151550b4).
You will probably find his post around page 50 of LOS thread about that.
He said that he will be not push this change to build since it will break LOS14 -> LOS15.1 transition when doing an OTA (user data will be corrupted if I remember correctly).
If you wondered why this tutorial is long and "complicated" like people said before then as you can see it turns out that data transition could be done with simply doing nandroid backup and then restoring it. These step are 90% of this tutorial due to bugs which are in lineage TWRP and "bugs" because that TWRP is backing up ROM with lockscreen settings which are breaking every time when restoring from backup. Also removing backup data step is necessary because these files will slow down encryption and will be not placed in /sdcard so people will forget about it probably and wonder what is eating so much space.
Click to expand...
Click to collapse
Ok, I understand. I think that some things in lineage wiki for p2 must be more clear. Starting from the guide for going from stock ROM to lineage 15.1...

matteo0026 said:
Ok, I understand. I think that some things in lineage wiki for p2 must be more clear. Starting from the guide for going from stock ROM to lineage 15.1...
Click to expand...
Click to collapse
Yeah, wiki instructions are a big mess. You actually need to perform most of steps I've written and described here if coming from another ROM (Steps 1 - 8) and you can do this few different ways
Maybe I will shorten this tutorial by fixing some aspects of TWRP and then request it to be included in the wiki so it will be easier for everyone.

Kielbek said:
Yeah, wiki instructions are a big mess. You actually need to perform most of steps I've written and described here if coming from another ROM (Steps 1 - 8) and you can do this few different ways
Maybe I will shorten this tutorial by fixing some aspects of TWRP and then request it to be included in the wiki so it will be easier for everyone.
Click to expand...
Click to collapse
Yes, for example for going from stock to los15.1 the right steps are:
- unlock bootloader and install official twrp 3.2.3-0
- (in case, do a backup)
- wipe system, data, cache and dalvik
- format data in ext4 (with official kernel, with yours I think it's not needed)
- install treble twrp
- wipe system, data, cache and dalvik another time
- install los15.1 (+ in case your kernel) + gapps and eventually addonsu or magisk
- reboot system

matteo0026 said:
Yes, for example for going from stock to los15.1 the right steps are:
- unlock bootloader and install official twrp 3.2.3-0
- (in case, do a backup)
- wipe system, data, cache and dalvik
- format data in ext4 (with official kernel, with yours I think it's not needed)
- install treble twrp
- wipe system, data, cache and dalvik another time
- install los15.1 (+ in case your kernel) + gapps and eventually addonsu or magisk
- reboot system
Click to expand...
Click to collapse
Yep, the only difference is that I suggest to use "fastboot boot recovery.img" with official twrp instead of flashing it directly to /recovery partition to prevent meaningless excessive data writing here. NAND will last for longer.

Kielbek said:
Yep, the only difference is that I suggest to use "fastboot boot recovery.img" with official twrp instead of flashing it directly to /recovery partition to prevent meaningless excessive data writing here. NAND will last for longer.
Click to expand...
Click to collapse
You are right, but I think NAND is not a problem, we are going to flash recovery maybe 10-20 times in all the device's life, no more

I am now on los15.1 with ext4 data partition which is encrypted. So can I direclty update recovery to this one or I need to do something else ?

Mrinmay Medhi said:
I am now on los15.1 with ext4 data partition which is encrypted. So can I direclty update recovery to this one or I need to do something else ?
Click to expand...
Click to collapse
Yes, of course you can directly update it. If you're on EXT4 it will work for you just fine like version from LOS wiki and maybe even better. Assuming to changelog this version fixes OTAs on encrypted devices. Only F2FS users need to reformat their data.

Hopefully when lineage os 16 released, treble twrp can format data properly, and decrypt/format/use right f2fs system...

mahmutpekkara said:
Hopefully when lineage os 16 released, treble twrp can format data properly, and decrypt/format/use right f2fs system...
Click to expand...
Click to collapse
There's no doubt that it will use newer F2FS version. Not sure about TWRP tho. Maybe I will look into it.

Kielbek said:
There's no doubt that it will use newer F2FS version. Not sure about TWRP tho. Maybe I will look into it.
Click to expand...
Click to collapse
Please do, we need one dedicated TWRP. Also thx again.:angel:

@Kielbek hi does it fix 1689mhz stuck speed bug?

Cuvillier said:
@Kielbek hi does it fix 1689mhz stuck speed bug?
Click to expand...
Click to collapse
What do you mean by this? I don't have such problems.

@Kielbek
How can we disable force encrypt from the kernel?

Related

Samsung galaxy tab a 10.1 cant mount data

Had this fixed on my first one . Had to return it and I cant find how i fixed it. Rooted. TWRP gives error message cant mount data. I cant backup or restore. Can someone point me to the fix, please?
Please note any instructions contained within this post are to be followed AT YOUR OWN RISK. I am not responsible for data loss, device failure, or any other form of damages resultant from the below post.
Final Edit: Method below tested and working on my SM-T580. Please read entire post before making any device modifications.
The reason you cannot mount /data is because TWRP does not support Samsung encryption, and your /data partition is encrypted by default. To fix this, you must disable encryption and FORMAT (not just wipe) your /data partition. You will lose all data on your device by doing this.
To disable encryption you must flash this ZIP file by ashyx via TWRP. I will update this post momentarily with the link.
Edit: Procedure that worked for me is as follows: [YOU MUST HAVE A ROM FILE TO REINSTALL]
-oem unlock and flash twrp
-format data
-wipe cache, dalvik, system, and data
-back out to main menu and reboot recovery
-flash your rom of choice back onto the device, I personally am using Fenix v2 found on XDA
-flash ashyx zip *not sure if this is actually necessary but it couldnt hurt, I flashed this file at this time
-reboot system
-then reboot to recovery to flash xposed, sd patch, etc
-you will see that twrp successfully mounts /data
Good luck!
REtails said:
Please note any instructions contained within this post are to be followed AT YOUR OWN RISK. I am not responsible for data loss, device failure, or any other form of damages resultant from the below post.
The reason you cannot mount /data is because TWRP does not support Samsung encryption, and your /data partition is encrypted by default. To fix this, you must disable encryption and then FORMAT (not wipe) your /data partition. You will lose all data on your device by doing this.
To disable encryption you must flash this ZIP file by ashyx via TWRP. I will update this post momentarily with the link.
Edit: There you go, so to recap: backup important data, reboot to recovery, flash zip, reboot to recovery, format data, reboot to system.
Click to expand...
Click to collapse
NO joy. See my post in stock ROM above (below now I guess...)
tennessee_titan said:
NO joy. See my post in stock ROM above (below now I guess...)
Click to expand...
Click to collapse
What? Not sure what you meant but it seems there is more to it than this. For some reason my device is forcing encryption across all sorts of wipes and such so I am currently trying to figure this out as well, will update if/when I figure it out
Edit: got it, updating post and sending you a PM

Problem with LineageOS

Hi all,
I'm with problems in Lineage OS.
I'm trying install Unofficial version under Official, but when I try usying TWRP, they show me this error:
" Can't install this package on top of incompatible data. Please try another package or run a factory reset"
I delete the "assert" section but the error persist.
Can any people help with this?
Thanks in advanced!
Rodrigo Possi
possi.rodrigo said:
Hi all,
I'm with problems in Lineage OS.
I'm trying install Unofficial version under Official, but when I try usying TWRP, they show me this error:
" Can't install this package on top of incompatible data. Please try another package or run a factory reset"
I delete the "assert" section but the error persist.
Can any people help with this?
Thanks in advanced!
Rodrigo Possi
Click to expand...
Click to collapse
Did you wipe cache/data/system/Dalvik prior to installation of the unofficial Lineage OS-OMS? The unofficial and official builds don't mix - if you wish to switch between the two, you must wipe your device (unless you're dualbooting). Of course, by doing this, all data and your official Lineage OS system apart from your internal storage/SD card will be erased, make backups before you proceed. Your TWRP backup will live on your internal storage btw.
echo92 said:
Did you wipe cache/data/system/Dalvik prior to installation of the unofficial Lineage OS-OMS? The unofficial and official builds don't mix - if you wish to switch between the two, you must wipe your device (unless you're dualbooting). Of course, by doing this, all data and your official Lineage OS system apart from your internal storage/SD card will be erased, make backups before you proceed. Your TWRP backup will live on your internal storage btw.
Click to expand...
Click to collapse
I didn't, only cache and dalvik. I would like install without lost my data and settings Have any way for I install changing the updater-script?
I would like try install only change this script first if I have any problem, there yes I'll do a clean install.
Thanks in advanced!
possi.rodrigo said:
I didn't, only cache and dalvik. I would like install without lost my data and settings Have any way for I install changing the updater-script?
I would like try install only change this script first if I have any problem, there yes I'll do a clean install.
Thanks in advanced!
Click to expand...
Click to collapse
I don't know of a way to modify the update script, and in any case, I still would suggest your data (this is your app data and settings, not your photos and other media stored on your internal storage) be wiped along with your system. As I mentioned above, the official and unofficial builds are quite different, and trying to flash one on top of the other without performing a wipe of your system, (app) data, Dalvik and cache (no need to wipe your internal storage for most cases) will give you problems. It's even mentioned in the instructions for installing Lineage OS OMS https://forum.xda-developers.com/moto-g4-plus/development/xt16xx-cyanogenmod-14-1-alpha-t3492274
If you don't wish to wipe your device, then staying on the official Lineage OS might be a wise option.
echo92 said:
I don't know of a way to modify the update script, and in any case, I still would suggest your data (this is your app data and settings, not your photos and other media stored on your internal storage) be wiped along with your system. As I mentioned above, the official and unofficial builds are quite different, and trying to flash one on top of the other without performing a wipe of your system, (app) data, Dalvik and cache (no need to wipe your internal storage for most cases) will give you problems. It's even mentioned in the instructions for installing Lineage OS OMS https://forum.xda-developers.com/moto-g4-plus/development/xt16xx-cyanogenmod-14-1-alpha-t3492274
If you don't wish to wipe your device, then staying on the official Lineage OS might be a wise option.
Click to expand...
Click to collapse
Thank you so much, I'll do a nandroid backup and try install following this tutorial. Other doubt, Can I use in this unofficial version the kernel elemental x or is better keep the original?
possi.rodrigo said:
Thank you so much, I'll do a nandroid backup and try install following this tutorial. Other doubt, Can I use in this unofficial version the kernel elemental x or is better keep the original?
Click to expand...
Click to collapse
I recall from what Silesh has mentioned is that the commits from ElementalX are present in his kernel, thus the benefits should be seen in the unofficial stock Lineage OS kernel and so you don't necessarily need the ElementalX kernel. If you wish to use the ElementalX kernel with the latest builds of Lineage OS-OMS, and there is nothing stopping you doing so, you need to flash the sensorhub firmware, else you'll lose sensors like your fingerprint sensor (if you have a G4 Plus, that is - I don't know if other sensors are affected on non-Plus models as well if you don't flash this). The firmware can be found here https://forum.xda-developers.com/showpost.php?p=71360979&postcount=2723
To install said firmware if you need it (credit to rahulsnair for the procedure https://forum.xda-developers.com/showpost.php?p=70716729&postcount=170):
Download the zip and extract, you should get a sensorhubfw.bin file. Copy this .bin file to your adb directory.
Connect your device to your computer and check adb can detect your device using 'adb devices'
Staying in adb, execute the command 'adb push sensorhubfw.bin /etc/firmware' (without the quotation marks). This will copy the sensorhub file to the /etc/firmware directory on your phone.
Reboot and hopefully you should have sensors back.

[DISCUSSION] Encryption Thread

First things first:
1. This is not a thread about how to flash ROMs, recoveries or use Android SDK and ABD or fastboot commands. If you have questions about the basics, please keep them in @Funk Wizard's excellent thread created for that purpose:
OnePlus 5T: Unlock Bootloader | Flash TWRP | Root | Nandroid & EFS Backup & More !!
2. This thread is not the place to discuss the merits of encryption or decryption.
3. I'm not responsible for what you do to your own device. Read, think, read more, re-think, wipe, flash in that order.
4. This OP and the following posts will be updated as the discussion develops, so please check back here from time to time.
Now on to the discussion
There has been a lot of talk lately about encryption, decryption and the benefits and liabilities of each. Obviously having your device encrypted is a gain for security, something we should try to keep if possible. But encryption methods can vary, which is a problem for flashaholics like myself. When you flash a new ROM that cannot read the encryption of the previous ROM, /data must be formatted, causing the loss of /sdcard - pictures, music, files, etc.
Understanding the Problem
The issue seems to revolve around Qualcomm's "KeyMaster" encryption keys. While both Nougat and Oreo use FBE (File Based Encryption), by default they use different encryption keys, as pointed out by dev @codeworkx -- Nougat and Oreo 8.0 use KeyMaster 1 while Oreo 8.1 uses KeyMaster 3. So when an Oreo 8.1 ROM is flashed, it either can't access /data (requires decryption or formatting /data) or the ROM reformats /data itself, like early beta Lineage 15.1 builds. Likewise, reverting to a Nougat or Oreo 8.0 build will cause the same problem. Apparently, moving to KeyMaster 1 to 3 works (ie, flashing from OOS to Omni/Lineage) but reverting from Keymaster 3 back to 1 doesn't. When this happens, OOS can still decrypt with your PIN/password but TWRP can't.
One solution is to run unencyrpted, for which you may find threads in the How-To section. This discussion is about how to stay encrypted and flash back & forth between ROMs without loosing all of your data.
Links on the subject:
https://source.android.com/security/encryption/file-based
I look forward to your contribution to this discussion! :good:
Reserved
Just dropping this here:
mad-murdock said:
If only someone would be advanced in linux FBE, used tools and libraries. There surely is a way to remove encryption with a flashable .zip. _IF_ current TWRP has the needed tools onboard.
I hope one day we get encrypt/decrypt options in TWRP - where it belongs.
Click to expand...
Click to collapse
Yes, NOW I have seen this thread. Thanks for mentioning.
Seems useful.
After a bit of google kicking, I found this: https://source.android.com/security/encryption/file-based
Seems a good start on the topic. Maybe add it to a list of (hopefully growing) links?
Wow. Seems like this didn't work out that well.
mad-murdock said:
Wow. Seems like this didn't work out that well.
Click to expand...
Click to collapse
1. Rather than understand and deal with it, lots of people decrypt.
2. The issue hasn't gone away. Give it time.
Great information to those who recently owned an OP even if they have knowledge how to flash ROMs. (Including me)
Thanks!
I've stumbled across another issue for investigation. While experimenting yesterday, I discovered that @codeworkx TWRP 3.2.1-0 for Oreo (8.0 and 8.1) is able to read stock OOS/OOS B1 encryption until it is backed up in TWRP, an Oreo 8.1 ROM is flashed (eg, Omni, Lineage), and OOS is restored. After that, TWRP cannot decrypt /data with the correct PIN/password of the restored OOS ROM or "default_password". It doesn't matter if the nandroid was taken with or without a PIN/password, if the PIN/password is removed from the Oreo 8.1 ROM before restoring the nandroid, etc. Codeworkx suspects it has to do with how the passwords are being stored between 8.0 and 8.1.
And before you ask, I never formatted /data or decrypted & re-encrypted. The contents of /sdcard survived every flash and nandroid restore. Every ROM flashed was able to access /data with the correct PIN/password including the restored OOS. Only TWRP can't read /data with the correct password.
Also, I've left recovery systemless. That means my nandroid backups are only of data, and I restore by flashing the stock OOS ROM and only restoring the data nandroid. So zero changes have been made to system.
the Doctor said:
I've stumbled across another issue for investigation. While experimenting yesterday, I discovered that @codeworkx TWRP 3.2.1-0 for Oreo (8.0 and 8.1) is able to read stock OOS/OOS B1 encryption until it is backed up in TWRP, an Oreo 8.1 ROM is flashed (eg, Omni, Lineage), and OOS is restored. After that, TWRP cannot decrypt /data with the correct PIN/password of the restored OOS ROM or "default_password". It doesn't matter if the nandroid was taken with or without a PIN/password, if the PIN/password is removed from the Oreo 8.1 ROM before restoring the nandroid, etc. Codeworkx suspects it has to do with how the passwords are being stored between 8.0 and 8.1.
And before you ask, I never formatted /data or decrypted & re-encrypted. The contents of /sdcard survived every flash and nandroid restore. Every ROM flashed was able to access /data with the correct PIN/password including the restored OOS. Only TWRP can't read /data with the correct password.
Also, I've left recovery systemless. That means my nandroid backups are only of data, and I restore by flashing the stock OOS ROM and only restoring the data nandroid. So zero changes have been made to system.
Click to expand...
Click to collapse
""And before you ask, I never formatted /data or decrypted & re-encrypted. The contents of /sdcard survived every flash and nandroid restore. Every ROM flashed was able to access /data with the correct PIN/password including the restored OOS. Only TWRP can't read /data with the correct password""
So Do you mean to say I can revert back to OOS OB-1 by flashing it over Omni/LOS/etc via TWRP without formatting Data, and later on restoring Nandroid data of OOS OB-1.
shail139 said:
""And before you ask, I never formatted /data or decrypted & re-encrypted. The contents of /sdcard survived every flash and nandroid restore. Every ROM flashed was able to access /data with the correct PIN/password including the restored OOS. Only TWRP can't read /data with the correct password""
So Do you mean to say I can revert back to OOS OB-1 by flashing it over Omni/LOS/etc via TWRP without formatting Data, and later on restoring Nandroid data of OOS OB-1.
Click to expand...
Click to collapse
Yes, but obviously TWRP would not be able to decrypt with a PIN/password set by OOS. That just means you would have to disable lockscreen protection in the ROM before going into TWRP.
the Doctor said:
Yes, but obviously TWRP would not be able to decrypt with a PIN/password set by OOS. That just means you would have to disable lockscreen protection in the ROM before going into TWRP.
Click to expand...
Click to collapse
By that way the steps to restore should be...
1. Backup of OOS OB-1 in TWRP should be taken post removal all securities PIN/PASSWORD/etc (On external drive/OTG)
2. Flash OOS OB-1 normally, clean flash, boot to system, no security should be set
3. Boot to TWRP, restore OOS OB-1 Backup Only "Data" should be checked via OTG drive
4. Reboot to system
"twrp-3.2.1-0-universal-codeworkx-dumpling" will be the TWRP to be used
Correct me if I am wrong in steps
so in this case, am i right to say that, so long i dont do nandroid restore, i wouldnt have problem with encryption/decryption regardless of what rom i'm flashing using codeworkx's universal TWRP?
usually i always clean flash new roms and i'm ok to go through the 'hassle' of reinstalling stuffs. if i want to go back to the previous rom, i'll just do a clean flash of the previous rom instead of reverting back via nandroid.
so technically so long i'm on the right TWRP, i'm fine with switching roms am i right?
thanks for sharing the findings as well!
gorillaCF said:
so in this case, am i right to say that, so long i dont do nandroid restore, i wouldnt have problem with encryption/decryption regardless of what rom i'm flashing using codeworkx's universal TWRP?
usually i always clean flash new roms and i'm ok to go through the 'hassle' of reinstalling stuffs. if i want to go back to the previous rom, i'll just do a clean flash of the previous rom instead of reverting back via nandroid.
so technically so long i'm on the right TWRP, i'm fine with switching roms am i right?
thanks for sharing the findings as well!
Click to expand...
Click to collapse
I tried a clean flash of OOS from TWRP as well, but even that didn't work. I think you'd have to restore factory encryption per this guide to get TWRP to be able to decrypt OOS again:
[How To] Revert to 100% stock OOS from Oreo 8.1 | Restore factory encryption
Again, you can flash, backup and restore in TWRP even if you don't. It just won't be able to decrypt /data with your OOS PIN/password, so you'd have to remove lockscreen security first.
the Doctor said:
I tried a clean flash of OOS from TWRP as well, but even that didn't work. I think you'd have to restore factory encryption per this guide to get TWRP to be able to decrypt OOS again:
[How To] Revert to 100% stock OOS from Oreo 8.1 | Restore factory encryption
Again, you can flash, backup and restore in TWRP even if you don't. It just won't be able to decrypt /data with your OOS PIN/password, so you'd have to remove lockscreen security first.
Click to expand...
Click to collapse
Formating /data is the only way to go back to 8.0 crypto (after booting fully stock) and then you can use you Nandroids from OOS to restore /data with PIN, face unlock all ON.
Been there, done that from 8.1 custom to OOS N.
Didn't use stock recovery, didn't use revert builds, there actually were none at the time, but I think they are unneeded anyway.
It's a cumbersome process because backing up internal storage and restoring it is a pain when you have a lot of data to carry around.
But it's pretty straight forward.
All this done on blu_spark TWRP.
The problem I noted above wasn't that OOS couldn't read or encrypt /data properly after the nandroid backup--TWRP couldn't read OOS's PIN/password. I had no problems restoring and running OOS after running Omni/Lineage. After I restored OOS, on first boot I entered the PIN and found that my fingerprints and face unlock still worked. But when I booted back into Codeworkx TWRP neither the PIN or "default_password" worked. I didn't try Blu_Spark.
IMO, what we ultimately want is an official TWRP that can decrypt without workarounds so we can avoid the cumbersome process or formatting /data and moving everything back to /sdcard.
Edit: Here is the exact sequence of what happened:
I came from OOS OB1 with /data formatted by the stock recovery, encrypted, with PIN/fingerprints/face unlock.
I booted Codeworkx recovery, entered the PIN, it decrypted properly, I did a nandroid backup of the Data partition.
Still in recovery, I wiped Dalvik-Art/Cache/System/Data, then flashed Omni, gapps, Magisk.
I ran Omni for a while, moved to Lineage using the same process as above. I never removed the PIN, and Codeworkx TWRP had no problems decrypting with it in Omni or Lineage.
After running Lineage for a while, I went back into Codeworkx TWRP, decrypted with my PIN (it worked), wiped as above, flashed OOS OB1 with the factory zip, wiped the Data partition, restored Data from nandroid, flashed Magisk, rebooted.
On first boot OOS asked for a PIN. I entered my PIN and found my fingerprints & face unlock still working.
VVV HERE IS THE PROBLEM STARTED VVV
When I booted back into Codeworkx TWRP it could not decrypt with my PIN. I booted back into OOS and removed my PIN, set lockscreen protection to "None". TWRP still could not decrypt /data. I tried "default_password" but no dice.
Revert back to Omni, remove PIN, reboot TWRP, still can't decrypt.
So something changed between when I restored OOS OB1 (TWRP could decrypt with the PIN) and after first boot (TWRP couldn't decrypt with the PIN). Also, why could TWRP decrypt with OOS OB1's PIN to do the nandroid backup from a clean flash and to restore the same backup after being on Omni/Lineage, but couldn't decrypt with it after the first boot of the OOS nandroid backup?
Again, formatting /data again is not an acceptable workaround. I think we want to understand what changed and solve the problem.
the Doctor said:
Again, formatting /data again is not an acceptable workaround. I think we want to understand what changed and solve the problem.
Click to expand...
Click to collapse
The mentioned /data format is not a workaround per se, it's the only working workflow to get things going once you find the need to get back to OOS for the time being.
Accepting that is part of the process!
Users should know this upfront so they don't find out the hard way.
I'm currently running OxygenOS 5.0.3 and my understanding is that it uses Keymaster1. If I'm now upgrading to LineageOS 15.1 it'd change to Keymaster3 but without the need of formatting.
However, if I'd want to revert to OxygenOS 5.0.3 with Keymaster1 I would have to format /data. Is my understanding correct?
Macusercom said:
I'm currently running OxygenOS 5.0.3 and my understanding is that it uses Keymaster1. If I'm now upgrading to LineageOS 15.1 it'd change to Keymaster3 but without the need of formatting.
However, if I'd want to revert to OxygenOS 5.0.3 with Keymaster1 I would have to format /data. Is my understanding correct?
Click to expand...
Click to collapse
My experience has been that the ROM can decrypt without any issues, but TWRP can't decrypt without formatting /data with the stock recovery.
the Doctor said:
My experience has been that the ROM can decrypt without any issues, but TWRP can't decrypt without formatting /data with the stock recovery.
Click to expand...
Click to collapse
As previous posters have alluded to, use "twrp-3.2.1-0-universal-codeworkx-dumpling.img". This is able to decrypt 5.0.3.
wunderdrug said:
As previous posters have alluded to, use "twrp-3.2.1-0-universal-codeworkx-dumpling.img". This is able to decrypt 5.0.3.
Click to expand...
Click to collapse
Right. Flash Omni or Lineage, then go back OOS and try it again as Macusercom says in the post I quoted.

[FIX][8.1][Treble]Decryption Unsuccessful and TWRP Internal Storage 0MB

As the tittle says, this is my current workaround for issues that happened after most people update their AOSP based ROMs after 3rd July 2018.
Decryption Unsuccessful
Q: Why does this happens ?
A: There's some weird issues with the latest AOSP based ROM that makes encrypted ext4 based data partition unable to be decrypted in both system and older version of TWRP if you're encrypted before (intentionally or unintentionally). This however doesn't apply to F2FS and unencrypted ext4 data partition.
Q: How do I solve this ?
A: There's 2 ways you can do to solve this issue.
The best way and the most recommended way is to repartition your data into F2FS. However it does require you to do a backup beforehand since this will wipe everything in your internal storage.
1. Backup your internal storage from TWRP (either to a SD card or PC via ABD)
2. Format it by going into TWRP and select Format and choose "wipe data"
3. Type "yes" and let the process end.
4. Flash your ROM and GApps.
5. Finish the setup without setting any screen lock so that it doesn't encrypt your data partition.
-Or-
The other way does is to install a custom kernel is made after 20 July 2018
List of kernel that can boot successfully without the need to wipe /data :
-Xenial b25x or newer
-Revolt EAS-R13
(Got kernel that works and doesn't show up here? TELL ME, I'll add it to my list for everyone's reference)
Link for the working TWRP that can detect Internal Storage :
Jairus' modded TWRP
https://androidfilehost.com/?fid=5862345805528049168
Or you can look up Orange Fox recovery
(link will be added soon)
Good Stuff Also This Happened to me while i was using the Android P DP3 i tried twrp and redwolf and was the same i flashed the Orange Fox and it worked
Does this twrp can flash both treble and non treble ROM?
eko_epe said:
Does this twrp can flash both treble and non treble ROM?
Click to expand...
Click to collapse
Yes, it does
AkmalWarrior said:
Yes, it does
Click to expand...
Click to collapse
Ok i'll try. Thanks
As the OP said, OrangeFox TWRP Recovery (R6-Beta) can decrypt encrypted data partitions.
DarthJabba9 said:
As the OP said, OrangeFox TWRP Recovery (R6-Beta) can decrypt encrypted data partitions.
Click to expand...
Click to collapse
TWRP and redwolf too (find on telegram)
Envoyé de mon Redmi Note 4 en utilisant Tapatalk
DarthJabba9 said:
As the OP said, OrangeFox TWRP Recovery (R6-Beta) can decrypt encrypted data partitions.
Click to expand...
Click to collapse
*Only in recovery, not in boot. The only way to fix decryption unsuccessful on boot is to either repartition data to F2FS or flash a custom kernel that's made after 20 July. List on working kernels is on main thread.
First I tried orange fox beta and it showed my internal storage
Then I flashed the RR endless
But the encryption was still there
Then I tried the twrp from this thread and flashed rom with latest xenial
And it worked no problem
Thank you
How for steps come from nougat Rom up to Oreo, should i flash xenial kernel directly after the ROM flashed? i want flash Aicp Oreo currently i'm on Los14.1
DarksTor said:
How for steps come from nougat Rom up to Oreo, should i flash xenial kernel directly after the ROM flashed? i want flash Aicp Oreo currently i'm on Los14.1
Click to expand...
Click to collapse
Sine you are using nougat i recommend to format data (wipes internal storage) so take a backup if you want
And I have also seen users reporting bugs about aicp oreo on telegram so try some other ROMs like resurrection remix,screwd,lineage os extended,aex ........
All oreo Roms are now treble
So use treble twrp
And treble magisk
antony felix said:
Sine you are using nougat i recommend to format data (wipes internal storage) so take a backup if you want
And I have also seen users reporting bugs about aicp oreo on telegram so try some other ROMs like resurrection remix,screwd,lineage os extended,aex ........
All oreo Roms are now treble
So use treble twrp
And treble magisk
Click to expand...
Click to collapse
Thanks,So i must format internal too,. It's ok but how if i want to comeback use nougat..? I hear who's downgrade after using oreo will get "encryption was interrupted" on any nougat los/aosp base rom,should be format internal for working back the devices..
I think by this thread shared we get solution for who's want to downgrade from oreo without facing encryption issue enytime for oreo back to nougat or vice
DarksTor said:
How for steps come from nougat Rom up to Oreo, should i flash xenial kernel directly after the ROM flashed? i want flash Aicp Oreo currently i'm on Los14.1
Click to expand...
Click to collapse
Flash the rom and test it out if you can boot it. I think most rom now have native support for ext4 based data partition.
If you can't boot however, try one of the kernel listed on the OP.
What if i flash Jairus' modded TWRP from fastboot? Does it solve the encryption problem without losing all the data? Also does it work on non-treble roms?
AkmalWarrior said:
Flash the rom and test it out if you can boot it. I think most rom now have native support for ext4 based data partition.
If you can't boot however, try one of the kernel listed on the OP.
Click to expand...
Click to collapse
Finally i can confirm for fixed "encryption was interrupted" by changing data partition into F2FS, yes i think it's only way to get free from that, i'v been test it back to back from oreo down to nougat or vice, no worry anymore
Below screenshot for oreo left side and nougat in right
ngydna said:
What if i flash Jairus' modded TWRP from fastboot? Does it solve the encryption problem without losing all the data? Also does it work on non-treble roms?
Click to expand...
Click to collapse
Read the OP, the recovery only help you boot into recovery and format your data partition or flash a custom kernel to allow you to boot into system as this issue does affect some older version of TWRP recovery. The recovery alone can't help you boot into system.
I took out my sdcard and did format data on the internal storage and now i can't mount my sdcard. Didn't think about the fact that removing the encryption on the internal storage would make it unable to recognize the encryption on the sdcard afterwards. Is there any way to fix this? Or did I just screw myself?
---------- Post added at 01:53 PM ---------- Previous post was at 01:00 PM ----------
When I reinstalled the rom and tried to boot it still asks me for my password which still works even though I can't boot because it says that the data is corrupted. But the encryption key should still be stored somewhere apparently. There must be a way to use it to decrypt the sdcard.

(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.

Categories

Resources