How to Defrag Your Windows Computer

Speed up your computer with the Windows disk defrag tool

What to Know

  • Make sure your drive is backed up and healthy, close any open programs, and plug in your PC.
  • Go to Control Panel > System and Security > Administrative Tools > Defragment and Optimize Drives.
  • Select Analyze, then choose the hard drive that says Needs optimization and select Optimize or Defragment disk.

This article explains how to defragment your Windows computer. Instructions apply to Windows 10, 8, and 7.

Prepare Your Computer for Defragmentation

Before you defrag your computer, you must take several steps. Read this entire procedure before you use the defrag utility.

  1. Make sure your work is backed up on an online backup service, a second local hard drive, an external hard drive, a flash drive, or a CD or DVD.

  2. Make sure the hard drive is healthy. Use CHKDSK to scan and fix the drive.

  3. Close any currently open programs, including virus scanners and other programs with icons in the system tray (on the right side of the taskbar).

  4. Make sure your computer has a constant source of power.

    If your computer shuts off while defragmenting, it may crash the hard drive or corrupt the operating system, or both. If you have frequent power issues or other outages, only use a defragmentation program with a battery backup.

Open the Defrag Program

The Windows defrag program is accessible through Control Panel in all versions of Windows. Still, the procedure for getting there is slightly different depending on which version of Windows you use.

  1. Open Control Panel. Alternatively, press WIN+R and enter control in the Run dialog box.

    Searching for Control Panel in Windows 10.
  2. Select System and Security. If View by shows icons, select Administrative Tools > Defragment and Optimize Drives.

    Selecting System and Security in Windows 10.
  3. Under Administrative Tools, select Defragment and optimize your drives. For Windows 7, select Defragment your hard drive.

    Selecting Defragment and optimize your drives in Windows 10.

A quicker way to get to the disk defrag utility is to run the dfrgui command in Windows 10 from the Run dialog box.

Analyze the Hard Drive

Before starting the defrag, analyze the drive first. This step checks the drive for fragments and reports how fragmented the drive really is, after which you can choose to defrag or skip the hard drive and not run a defrag.

  1. Choose Analyze (Windows 10, 8, and XP) or Analyze disk (Windows 7) to check for fragments on all the connected hard drives.

    Selecting Analyze in Windows 10 defrag.
  2. Under Status, note the fragmentation level shown next to each drive. If the fragmentation level seems high (above 20 percent) or if the Current status displays Needs optimization, move to the next step to defrag the drive. Otherwise, you're probably safe skipping the defrag.

    Windows Vista does not include an option to analyze the hard drive.

    Current status in Drive optimization in Windows 10.

Defrag the Hard Drive

If you chose to defrag the hard drive, it's only a click away. However, the button for defragging the drive is called something different in some versions of Windows.

  1. Under Drive, select the hard drive that shows Needs optimization under Current status.

    Selecting a drive to optimize in Windows 10.
  2. Select Optimize. For Windows 7, select Defragment disk.

    Selecting Optimize to begin hard drive defrag.

It could take anywhere from several minutes to several hours to defrag a hard drive. The time it takes to run a defrag on your hard drive depends on the number of file fragments the tool identifies, the size of the hard drive, and the speed of the computer.

We have found it's best to start the defrag and then go to bed. With luck, it'll be done when you wake up in the morning.

Should You Defrag Your Computer?

Files stored on a hard drive become fragmented over time, meaning that parts of the files are stored in separate areas of the drive instead of next to each other. When this happens, it can take longer for the OS to open the file. A defrag can fix this.

While there are lots of free, third-party defragmenters, you can use the Windows disk defragmenter without having to download anything since it's built into the operating system.

The Windows defrag tool runs automatically once a week in Windows 10, Windows 8, and Windows 7, so you probably don't need to defrag on your own. Run the analyzer first, and if it's less than 10 percent fragmented, the drive does not need to be defragged.

If you want to defrag on your own time, open the program anytime you want and run a manual defrag. You can get to it by searching through Windows or by browsing through Administrative Tools via Control Panel.

Defragging isn't necessary on solid-state hard drives since there aren't any spinning parts. Since the hard drive doesn't need to spin to find all the file's pieces, there isn't a lag between finding the file and the time it takes to open it.

A computer backing up

ikuvshinov / iStock

Was this page helpful?