A factory reset will usually remove malware, as viruses generally attach themselves to files. Running a factory reset essentially means you’ll be wiping all the data except default programs. In some rare cases, where the virus attaches itself to the RAM or to the recovery partition, the part of the hard drive where the factory reset settings are stored, even a hard reset may not fix the issue.