Advertisement

How to Defrag a Drive in Windows 10

Optimizing your PC's internal disk drive is a very important process which improves your PC's performance. Luckily, Windows includes a number of tools to perform to this important process. Today we will see, how you can defrag a drive in Windows 10.

Advertisеment


Out of the box, Windows 10 performs disk defragmentation once a week for hard drives and SSD TRIM operation for SSDs. During active use, hard drive performance suffers due to file system fragmentation which notably slows down the access time. SSDs have very fast access times for data stored in any part of the drive and do not need to defragmented but they need to be sent a TRIM command which tells the SSD controller to erase unused blocks which are no longer in use, so that when the time comes to actually write new data to those blocks, performance isn't affected.

Modern Windows versions are smart enough to pick the right optimization method and time period depending on your drive specifications. If you need to change the default schedule, you can do so for individual drives or disable it completely. See the following article:

Optimize Drives By Schedule In Windows 10

If you need to optimize your drives manually, here is how it can be done.

To defrag a drive in Windows 10, do the following.

 

  1. Open File Explorer.
  2. Navigate to the This PC folder.
  3. Right click the drive you want to defrag and select Properties from the context menu.Drive Context Menu Properties Windows 10
  4. Switch to the Tools tab and click the button Optimize under Optimize and defragment drive.Drive Properties Tools Tab
  5. In the next window, click on the Analyze button to see if it needs to be optimized.Defrag A Drive
  6. To optimize the drive, click the Optimize button. If the file system on drive is more than 10% fragmented, then you should optimized it.

Defrag a Drive in Command Prompt

There is a way to optimize drives in the command prompt. Here is how it can be done.

  1. Open an elevated command prompt.
  2. Type the following command to optimize your C: drive:
    defrag C: /O
  3. Replace the C: portion with the drive letter you need to optimize and defrag,

The defrag command supports the following command line arguments and options.Defrag Command Line

Syntax:

defrag <volumes> | /C | /E <volumes> [<task(s)>] [/H] [/M [n] | [/U] [/V]] [/I n]

Where <task(s)> is omitted (traditional defrag), or as follows:
/A | [/D] [/K] [/L] | /O | /X

Or, to track an operation already in progress on a volume:
defrag <volume> /T

Parameters:

Value Description

/A Perform analysis on the specified volumes.

/C Perform the operation on all volumes.

/D Perform traditional defrag (this is the default).

/E Perform the operation on all volumes except those specified.

/G Optimize the storage tiers on the specified volumes.

/H Run the operation at normal priority (default is low).

/I n Tier optimization would run for at most n seconds on each volume.

/K Perform slab consolidation on the specified volumes.

/L Perform retrim on the specified volumes.

/M [n] Run the operation on each volume in parallel in the background.
At most n threads optimize the storage tiers in parallel.

/O Perform the proper optimization for each media type.

/T Track an operation already in progress on the specified volume.

/U Print the progress of the operation on the screen.

/V Print verbose output containing the fragmentation statistics.

/X Perform free space consolidation on the specified volumes.

For example, you can optimize all your partitions at once, run the command:

defrag /C /O

Defrag a Drive in PowerShell

It is possible to defrag a drive in Windows 10 using PowerShell. You need to use the Optimize-Volume cmdlet. Open an elevated PowerShell and type the command below.

Optimize-Volume -DriveLetter drive_letter -Verbose

Replace the "drive_letter" portion with the actual drive letter of your partition. For example, the following command will optimize the drive D:

Optimize-Volume -DriveLetter D -Verbose

Using this cmdlet, you can analyze the specified partition for fragmentation statistics. The command looks as follows:

Optimize-Volume -DriveLetter C -Analyze -Verbose

This will show the fragmentation statistics for drive C.Powershell Analyze Drive

If you are using an SSD drive, the following command should be used.

Optimize-Volume -DriveLetter YourDriveLetter -ReTrim -Verbose

Windows 10 Trim Ssd

Replace the YourDriveLetter portion with your solid state drive partition letter.
Please refer to the following article:

How to Trim SSD in Windows 10

That's it.

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Advertisеment

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

2 thoughts on “How to Defrag a Drive in Windows 10”

  1. Defrag HDD – Boot Windows USB – Repair – Troubleshoot – CMD
    c:
    cd windows
    cd system32
    defrag c: /u

Leave a Reply

Your email address will not be published.

css.php
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.