In some new models, when installing a custom recovery,
/data partition won't mount. To fix that I need to wipe partition. How can I fix without losing data?
Android M added support for
/data encryption, and Android N made it mandatory.
Old custom recoveries' having trouble mounting
/data is primarily because they aren't capable of decrypting it. Newer recoveries will prompt for a password (or pattern) before they attempt to access
/data (or nothing if you don't have a locked lockscreen).
Solution: Give up that recovery and get another one, but this time make sure the recovery you're installing supports
/data decryption (like TWRP).