Can I safely do a factory reset without losing root? Sadly my quesiton isn't that simple. To make sure everyone unerstands I will explain as short but specific as possible:

Initial: stock state, not rooted, nothing special


I updated my HTC One M8 to Android 5.0 (Lollipop) and noticed, that it drains my battery waaay faster than before and also lags pretty bad (almost every press of a button).
I searched for fixes online but couldn't find anything that may work except for a factory reset. Since it's almost impossible to backup all apps including data without root (e.g. titanium backup) I thought I may as well root my device, so I'm prepared for future restores (as I found out it's particularly easy to root an htc device, I was relieved I'm a noob when it comes to rooting).


I then did a factory reset and rooted my HTC One M8, installed SuperSU and all that stuff, you know.
It actually ran faster than before the Android 5.0 Update and the battery drain also seemed to be OK.

This Monday I woke up to a completely depleted mobile data usage (had about 450MB left - all gone over night). I forgot to turn on WiFi as I went to sleep. Below is the data usage of that night. I set everything I can (Play Store Updates and HTC Backups, as far as I know) to WiFi only, because 1GB of monthly mobile data seldom is enough for me.



I contacted HTC Support Chat and that lady told me to go to Settings -> Apps -> Reset App settings and restart my phone by pushing VolumeDown + VolumeUp + Power Button.  I did that and it seemed like my phone is as slow as before I did the factory reset.
I still don't know why the heck my phone used so much mobile data that night. I just hope this won't happen again. If you know why or how to prevent this, feel free to tell me!



Now I'm here with a rooted HTC One M8 with Android 5.0.1 and the same problems as in the beginning of this nerve-racking process. I searched a lot for solutions of the battery drain after the Lollipop update, but couldn't find anything helpful.

So my question is Can I perform a factory reset without losing root? because that's what helped me in the beginning. But of course I would be very happy about solutions addressing the extreme battery drain and lags I'm experiencing. 

In Settings -> Power consumption there (almost) always is Google Play Services at the top. I found some solutions on how to keep this from draining my battery all the time, but they include messing with more root apps and I'm not sure if my device will also run faster after doing that.
Recoveries like TWRP and Philz Touch checks for root verification and in the scenario of you losing root after  factory reset, boot into your custom recovery, attempt for a normal reboot and the recovery will offer to root the device. Take the offer. Come back to Android and install SuperSU from Play Store as usual. This worked well with my Android 4.2.1, 4.4.2, COS12 and stock Android 5.1 ROMs. 

Note: do not use the said approach on a ROM running Android Marshmallow. It may cause boot issues which you might not be able to solve unless you do a clean and full flash of a device specific ROM or manually reverse the steps TWRP used to root the device.

As of now, to root a ROM prefer the flashable zip for SuperSU stable and flash it through your custom recovery. In case of installation issues, refer to this XDA thread. 

Related: I&#39;ve installed a custom recovery image, but not yet rooted my phone. How can I install SuperSU and subscribe to automatic updates?



SuperSU app offers to move itself into system partition which would make it a system app and invulnerable to any factory reset. The option is available under its settings as Install SuperSU into /system. 

(As of now however, for ROMs rooted with system-less root mode SuperSU doesn't provide the said option.)



About battery drain, per my experience with it in Android 4.2.1, 4.4.2 and 5.0.1 I can recommend Greenify app in Boost mode. Boost mode requires Xposed Framework1 installed. 



1  Xposed Framework: Android 4.x, Android 5.x and 6.x