A factory reset removes most viruses, but not all of them

A factory reset wipes your device back to the state it left the manufacturer, which deletes the files where most viruses live. For the majority of infections — malware that hides in your documents, photos, downloads, or installed programs — a factory reset will remove them. But some viruses are designed to survive a reset by hiding in the firmware, which is the permanent software that runs your device before Windows or iOS even loads. Those are rare, but they exist.

The practical answer for most people is yes: a factory reset will get rid of your virus problem. But it comes with a cost — you lose all your files, photos, and settings unless you back them up first. And if you restore from an old backup that was already infected, you can bring the virus back.

Key Takeaways

  • A factory reset deletes the files where most viruses hide, so it removes the majority of infections.
  • Some advanced viruses hide in firmware (the permanent software layer), which survives a reset, though these are uncommon on personal devices.
  • You lose all your files, photos, and programs during a reset unless you back them up to an external drive or cloud service first.
  • If you restore from a backup made before the infection, you can reintroduce the virus, so only restore files you know are clean.
  • For most people, running antivirus software first is faster and safer than a reset, and only reset if the antivirus does not solve the problem.

Where viruses actually hide on your device

Most viruses live in files you can see and delete — your downloads folder, installed programs, email attachments, or documents. When you do a factory reset, the device erases everything on the main storage and reinstalls the operating system fresh. All those infected files go away.

Firmware is different. It is the software layer that runs before your operating system loads — think of it as the device's permanent instructions. On a computer, firmware lives on the motherboard. On a phone, it is built into the processor. A factory reset does not touch firmware because the reset process itself needs firmware to run. A virus that embeds itself in firmware can survive the reset and reinfect your device after it restarts.

In practice, firmware viruses are extremely rare on personal computers and phones. They are expensive to create and require deep knowledge of a specific device model. They show up in targeted attacks against specific people or organizations, not in the random malware most people encounter. If you picked up a virus from a suspicious website or email, it almost certainly lives in your files, not your firmware.

What happens to your files during a factory reset

A factory reset erases everything on your device's main storage — all your photos, documents, programs, email, browsing history, and settings. The device then reinstalls the operating system as if it just came from the store. You get a clean slate, but you lose everything you created or installed.

This is why backing up before a reset matters. You can back up to an external hard drive, a USB stick, or a cloud service like OneDrive, Google Drive, or iCloud. After the reset completes and your device is clean, you can restore your files from the backup. But here is the catch: if your backup was made while the virus was already on your device, restoring it will bring the virus back.

To avoid this, only restore files you know are safe — documents, photos, and videos are usually fine. Be cautious about restoring installed programs, because the virus might have hidden itself inside one of them. If you are unsure, restore only your documents and photos, then reinstall your programs fresh from the official app store or the publisher's website.

When to reset versus when to use antivirus software

Before you reset, try running antivirus software first. Programs like Windows Defender (built into Windows), Malwarebytes, or Avast can scan your device, find infected files, and delete them without erasing everything else. This takes an hour or two and solves the problem for most people. A reset should be your second choice, not your first.

Reset your device if antivirus software does not find anything but your device still behaves strangely — running slowly, showing ads you did not click, or opening programs on its own. Reset if antivirus finds a virus but cannot remove it (some viruses lock files so they cannot be deleted while the operating system is running). Reset if you bought a used device and want to start completely fresh.

A reset also makes sense if your device is old and slow anyway. You get a fresh operating system, which often runs faster on older hardware, and you eliminate any accumulated junk at the same time. Just remember to back up your files first, and only restore the ones you are confident are clean.

How to back up before you reset

On Windows, open File Explorer and look for your Documents, Pictures, and Downloads folders. Copy these to an external hard drive or USB stick by right-clicking the folder, selecting "Copy", then navigating to the external drive and selecting "Paste". This takes a few minutes to an hour depending on how much you have.

On Mac, open Finder, click on your username in the sidebar, then drag your Documents and Pictures folders to an external drive. On iPhone or iPad, open Settings, tap your name at the top, select iCloud, and turn on iCloud Drive and Photos — this backs up to Apple's servers automatically. On Android, open Settings, search for "backup", and turn on Google One backup, which saves your photos and some settings to Google's servers.

Cloud services are often easier than external drives because they work automatically in the background. But they are slower if you have thousands of photos or gigabytes of files. External drives are faster for large backups but require you to remember to plug them in.

The steps to do a factory reset safely

On Windows 10 or 11, open Settings, go to System, scroll down to Recovery, and click "Reset this PC". Choose "Remove everything" to erase all files and reinstall Windows. The process takes 30 minutes to an hour. Your device will restart several times — do not turn it off during this.

On Mac, restart your device and hold Command and R while it boots. This opens Recovery Mode. Click Utilities in the menu bar, then Terminal, and type diskutil secureErase freespace 0 / dev/disk0s2 to erase the drive completely. Then reinstall macOS from the recovery menu. This is more technical than Windows and takes longer.

On iPhone, open Settings, go to General, scroll to the bottom, tap Transfer or Reset, then Erase All Content and Settings. You will need your Apple ID password. On Android, open Settings, go to System, tap Reset, and select "Erase all data". You will need your Google account password. Both phone resets take 10 to 20 minutes.

After the reset completes, your device will restart and ask you to set it up as new. Do not restore from your old backup yet. First, run antivirus software to make sure your device is clean. If it passes a clean scan, then restore your backed-up files.

Signs your device might still have a virus after reset

If your device still runs slowly, shows unexpected ads, or opens programs on its own after a reset, the problem might not have been a virus. Slow performance after a reset usually means your device is old, your storage is almost full, or you have too many programs running at startup. Unexpected ads might be from a browser extension rather than a virus.

If you restored from a backup and the problem came back, your backup was infected. Wipe the device again, reset it a second time, and this time restore only documents and photos, not programs or settings. Reinstall your programs fresh from the official app store.

If the problem persists even after a clean reset with no restore, contact the device manufacturer's support line or take it to a repair shop. At that point, the issue is likely hardware failure, not a virus.

Frequently Asked Questions

Will a factory reset remove ransomware?

A factory reset will remove most ransomware from your device, but it will not decrypt your files. Ransomware locks your files with encryption, and the reset only deletes the program that did the locking. Your files stay locked. The only way to recover them is to restore from a backup made before the infection, or to pay the ransom (which is not recommended).

Can I reset my device if I forgot my password?

On Windows, you can reset without the password by using another admin account or a password reset disk. On Mac, you need your Apple ID password. On iPhone and Android, you need your Apple ID or Google account password respectively. If you have forgotten all of these, you will need to contact the manufacturer or visit a repair shop with proof of ownership.

How long does a factory reset take?

Windows and Mac resets take 30 minutes to two hours depending on your device's age and storage size. iPhone and Android resets take 10 to 20 minutes. Do not turn off your device or unplug it during the reset, or you may damage the operating system.

Will I lose my photos if I factory reset?

Yes, unless you back them up first. Photos stored only on your device will be deleted. If your photos are backed up to iCloud, Google Photos, OneDrive, or an external drive, you can restore them after the reset. Check your backup service before you reset to make sure your photos are actually there.

Is it safe to buy a used device without knowing if it was reset?

No. A used device might have viruses, spyware, or stolen accounts still on it. Ask the seller if they performed a factory reset before selling it. If they did not, do a reset yourself as soon as you get it home. If the device is locked with the previous owner's password, contact the manufacturer with proof of purchase to unlock it.