How to Defrag Your Windows Computer

Speed up your computer with the Windows disk defrag tool

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 right 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, the Windows disk defragmenter can be used right now without having to download anything since it's built in to the operating system. You can get to it by searching through Windows or by browsing through Administrative Tools via Control Panel.

Note: 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 the time it takes to find the file and the time it takes to open it.

01
of 04

Prepare Your Computer for Defragmentation

Picture of a shield and star on a circle

Before you defrag your computer, you must take a number of steps first. Read this entire procedure before you use the defrag utility.

  1. Make sure your work is backed up, like to 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 programs that are currently open, including virus scanners and other programs that have icons in the system tray (right-hand side of the taskbar).
  4. Assure your computer has a constant source of power. The important thing is to be able to stop the defragmentation process if there is a power outage.
    1. If you have frequent power issues or other outages, you should not use a defragmentation program without a battery backup.
    2. Important: If your computer does shut off while defragmenting, it may crash the hard drive or corrupt the operating system, or both.
02
of 04

Open the Defrag Program

Screenshot of the defrag tool listed in Control Panel in Windows 10
Windows 10 Defrag Tool in Control Panel.

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

  1. Open Control Panel.
    1. A fast way to do this in any version of Windows is through the Run dialog box (WIN+R). Just enter control to open Control Panel.
    2. Using Windows XP? Go instead to Start > All Programs > Accessories > System Tools > Disk Defragmenter.
  2. Go to System and Security, or System and Maintenance if you're on Windows Vista.
  3. Click or tap Administrative Tools.
    1. If you're on Windows 7 or Windows Vista, click Defragment your hard drive just below the Administrative Tools heading to open Disk Defragmenter.
  4. Windows 10 and Windows 8 users should launch the program called Defragment and Optimize Drives.

Tip: A much quicker way to get to the disk defrag utility is to run the dfrgui command in Windows 10–Windows Vista, or the dfrg.msc​ command in Windows XP. You can do this from the Run dialog box.

03
of 04

Analyze the Hard Drive

Screenshot of the Windows 10 defrag tool after the drives have been analyzed
Analyzing a Hard Drive in Windows 10.

Before starting the defrag, you'd be wise to analyze the drive first. This step checks the drive for fragments and reports back 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 the Analyze button (Windows 10/8/XP) or Analyze disk button (Windows 7) to check for fragments on all the connected hard drives.
  2. Take note of the fragmentation level shown next to each drive.
    1. If the level of fragmentation seems high (above 20 percent), move on to the next step to defrag the drive. Otherwise, you're probably safe skipping the defrag.
    2. Another way to know if you should defrag the hard drive is to read what the defrag tool says on the screen. If it says the drive is OK, then you're fine not running the defrag.

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

04
of 04

Defrag the Hard Drive

Screenshot of a hard drive being defragged in Windows 10
Defragging a Hard Drive in Windows 10.

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

  1. Select the hard drive you want to defrag.
  2. Click the button to start the defrag.
    1. Windows 10 and Windows 8 call it Optimize, Windows 7 uses the term Defragment disk, Vista users should select Defragment now..., and XP calls the button Defragment​.

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 entirely on the number of file fragments the tool identifies, the size of your hard drive, and the speed of your computer.