Although a factory data reset isn't something you should have to be doing often, there might be a time when you actually need to perform this process on your HTC One M9, whether it be as a means of attempting to fix corrupted software, or for the fact that you just want to start things off with a clean slate. Performing a factory reset will wipe all of your data on the internal storage of the HTC One M9 so be sure you have everything backed up before you start the process. There are also two methods for completing the factory reset, one which involves initiating the reset from the settings menu, and the other utilizing the hardware buttons. We'll go over both just in case.
As stated above the factory data reset process will wipe all of your data from the internal storage so you'll want to back it up either through and HTC account, your Google account attached to the device, or to your computer. In addition, if you have a microSD card inserted into your device, the factory reset screen will have a check box which allows you to wipe the data from the microSD card as well. If you're going to include this storage in the wipe make sure you have the data from the card backed up just as you did with any data on the phone's internal storage.
Once the backups are finished, proceed with the factory data reset by navigating to the settings menu, scrolling to backup and restore, and tapping on the reset phone option. Doing so will take you to the next screen which lists off all of the data which will be wiped from the device during the process, alongside the option for including the microSD card in the wipe. After you confirm you want to perform the reset the phone will begin to reboot and start the process, after which it will restart and power back on. From here you can proceed to restore all the data you wiped from wherever it was backed up.
Should you not be able to perform the factory data reset from the settings menu, you can still do so using the hardware buttons. The device must be off for this to work, so if it is not already off, power the phone down. From here, press and hold the volume up button, then press and hold the power button until you feel the phone vibrate and turn on. Once the white HTC splash screen appears, immediately release the power button but continue to hold down the volume up button until the Recovery mode screen appears. You should see options for rebooting the device, powering it down, as well as the option for factory data reset. To perform the factory data reset simply use the volume down button to scroll through the options until you have factory data reset highlighted, then press the power button to select it. After this the phone will begin to reboot and start the reset process, after which it will power back on, and you can begin to restore all your data.