[Redmi Note 9T] chaoscreater:
Using TWRP atm. Tried factory reset and format data from TWRP. It showed unable to mount data for some reason and so both wipe and format data failed.

UPDATE:

TWRP can't wipe or format, but OrangeFox can. Both TWRP and OrangeFox fail to backup Data partition, getting error "(createTarFork() process ended with ERROR: 255". Have no issues backing up other partitions. I've tried a couple of suggestions found online for error 255 but no luck.

I looked at the recovery.log file and the error at the very bottom says:

"Invalid encryption mode 'aes-256-xts:aes-256-cts:v1'"

I'm not using any dual apps, not using Island or multiple profiles, I'm just using stock MIUI with a single profile. This thread talks about different solutions and none of them work for me:

Backup fails after a user profile was added · Issue #1354 · TeamWin/Team-Win-Recovery-Project

I am running an official build of TWRP, downloaded from https://twrp.me/Devices/ I am running the latest version of TWRP I have read the FAQ (https://twrp.me/FAQ/) I have searched for my issue and ...

github.com

I:Data backup size is 14796MB, free: 88576MB.
...done
I:Backup Name is: '2021-11-04--23-03-31_RP1A200720011'
I:Backup_Folder is: '/external_sd/TWRP/BACKUPS/ifsc7pvk4hmrp7mv/2021-11-04--23-03-31_RP1A200720011'
I:Calculating backup details...
I:Backup_List: /data;
I:backup_path: /data
* Total number of partitions to back up: 1
* Total size of all data: 14796MB
* Available space: 93257MB
[BACKUP STARTED]
* Backup Folder: /external_sd/TWRP/BACKUPS/ifsc7pvk4hmrp7mv/2021-11-04--23-03-31_RP1A200720011
Invalid encryption mode 'aes-256-xts:aes-256-cts:v1'
Backing up Data (excl. storage)...
Backups of Data do not include any files in internal storage such as pictures or downloads.
Invalid encryption mode 'aes-256-xts:aes-256-cts:v1'
Breaking backup file into multiple archives...
I:Creating backup...
I:Creating tar file '/external_sd/TWRP/BACKUPS/ifsc7pvk4hmrp7mv/2021-11-04--23-03-31_RP1A200720011/data.f2fs.win000'
I:addFile '/data/bootchart' including root: 1
==> set selinux context: u:object_r:bootchart_data_file:s0
failed to lookup fscrypt tar policy for '/data/bootchart' - '5d9d3047000000000000000000000000'
I:Error adding file '/data/bootchart' to '/external_sd/TWRP/BACKUPS/ifsc7pvk4hmrp7mv/2021-11-04--23-03-31_RP1A200720011/data.f2fs.win000'
Error creating backup.
I:ERROR tarList for thread ID 0
Error creating backup.
I:InfoManager saving '/external_sd/TWRP/BACKUPS/ifsc7pvk4hmrp7mv/2021-11-04--23-03-31_RP1A200720011/data.info'
createTarFork() process ended with ERROR: 255

UPDATE 2:

Somehow fixed my issue, but not sure the exact steps.

FIrst of all, OrangeFox can't decrypt Data partition for some reason. I even tried to remove the screen lock on my phone and that didn't fix the issue. Obviously, if OrangeFox can't decrypt Data partition, it won't be able to back it up.

Whereas for TWRP, it can decrypt the Data partition but it still gives the same error 255 message during backup. Also, sometimes TWRP will not be able to decrypt the Data partition.

On both recoveries, I've tried to Format Data first (which removes the decryption). I'll then reboot into recovery and both recoveries will be able to see the Data partition decrypted. At this point, I can backup the Data partition without any issues, but obviously Data is empty atm.

However, if I let the phone boot up and go through the initial Android setup, it still shows as Encrypted in the Android settings. I think somewhere along the boot.img process, it's encrypting the Data partition during phone bootup?

So then I tried using this:

https://xdaforums.com/t/script-android-10-universal-mount-system-r-w-read-write.4247311/

but that didn't work, I got errors.

Then I tried this:

https://xdaforums.com/t/universal-dm-verity-forceencrypt-disk-quota-disabler-11-2-2020.3817389/

Before you use the above, make sure to backup all your other partitions first. I recommend using OrangeFox, because it is able to list partitions such as nvdata and back them up.

And while that flashed successfully, my phone wouldn't boot properly. It would just be stuck at a boot loop at the MIUI logo animation.

So I think eventually, the proper steps to fix the issue is probably something like:

- Format Data in TWRP.

- Install OrangeFox recovery and reboot to recovery (should go to OrangeFox).

- Format Data in OrangeFox.

- Backup all your partitions (including Data, which should be empty at this point).

- Install the Universal Mount System (should fail but I tried it anyway).

- Install the Universal dm-verity-forceencrypt-disabler.

- Install vbmeta.img (the one for TWRP)

- Let phone boot up and if done correctly, Android setting should show Encryption is disabled.

Also, in OrangeFox recovery, there's a setting for "disable force encryption" under OTA & ROM. I think I might have ticked that and it probably helped. Not sure.

- Reboot into recovery and now Data partition should be accessible and can be backed up.

UPDATE 3:

The previous solution didn't work on StaticOS (Android 12), but this new one does. Not sure of the exact steps I took, but goes something like this:

- In Fox Recovery, enable "disable force encryption" setting. Flash the ROM .zip file. BTW, as a sidenote, you can potentially just download the .zip from StatixOS and then replace all the ROM files inside with the files from a GSI.

- Install the .zip ROM and Fox Recovery should attempt to remove force encryption during the process.

- Format DATA and reboot to system.

- Phone should boot into Android setup wizard menu. Restart back to Recovery.

- Wipe DATA (not FORMAT DATA). Reboot again and it should hopefully allow you to access your Data partition when you boot back into recovery.

- Confirm that there is a OTA folder inside the Fox folder in your internal storage. If yes, then it should mean the next time you boot into recovery, it should decrypt all the folders inside Data partition and you should see a bunch of Android folders in Internal Storage.

UPDATE 4:

OK, I can confirm that by flashing this specific build "Disable_Dm-Verity_ForceEncrypt_02.24.2020.zip" and THEN restore stock boot.img, that allowed my phone to boot to System and I can see the phone storage is unencrypted.