In our rudiments of Android software repairs course , we differentiated between custom and stock recovery. A custom recovery on a device with encrypted userdata is synonymous with some issues. Two of which are Internal Storage (0MB) and looping into custom recovery mode after doing a factory reset.
What is userdata encryption?
Look under Under Settings > Security & Privacy > Encryption & Credentials > Encrypt phone. You’ll see Encrypted on a smartphone which supports userdata encryption.
This encryption is the reason you have 0MB internal storage or mount error in custom recovery. It hinders pattern / pin lock bypass and protects your data from unauthorized access.
I should mention that pattern or pin lock bypass is possible without data loss even on recent Android versions. However, this is talk for another day.
Why won’t the phone boot up to home screen after doing a factory reset?
A factory reset wipes userdata. With data encryption enabled, the device storage gets re-encrypted on first boot. For the wipe-encryption process to complete, the device needs to enter stock recovery mode. This means it’ll keep booting straight to recovery mode, hoping to find stock recovery.
The process fails if the device is running on a custom recovery. This is why the device appears to be stuck in custom recovery mode.
How to fix
You simply need to flash the stock recovery.img from the firmware, no need to flash the entire firmware. After flashing the stock recovery.img, boot up the device normally. The wipe-encryption process will complete and the device should boot to home screen
To avoid a re-occurrence, disable phone encryption.