How to Optimize and Defrag Drives in Windows 11

Maintaining storage drives in Windows 11 improves system performance, speeds up file access, and extends hardware lifespan. While mechanical hard disk drives (HDDs) require traditional defragmentation to consolidate split files, solid-state drives (SSDs) use the TRIM command to clear unused data blocks safely. This guide explains how Windows 11 manages both drive types and provides direct steps to optimize them manually or set up automatic schedules using built-in operating system tools.

The Difference Between Optimizing HDDs and SSDs

Before running maintenance tools, it is important to understand how Windows 11 handles different storage media:

How to Optimize Drives Using the Windows 11 Settings App

  1. Open Settings by pressing Windows Key + I.
  2. Navigate to System > Storage.
  3. Scroll down and click on Advanced storage settings.
  4. Select Drive optimization.
  5. In the Optimize Drives window, review the Media type column to ensure Windows correctly identifies your drives as Solid state drive or Hard disk drive.
  6. Select the drive you want to maintain:
    • For an HDD, click Analyze to check the fragmentation percentage, then click Optimize to begin defragmentation.
    • For an SSD, click Optimize to send the TRIM command.
  1. Press the Windows Key or click the search bar on the taskbar.
  2. Type Defragment and Optimize Drives and press Enter.
  3. Highlight the target drive from the list.
  4. Click Optimize. Windows 11 will automatically apply defragmentation to HDDs or TRIM optimization to SSDs.

How to Optimize Drives Using Command Prompt

You can also run optimizations using the Windows Command Prompt with administrative privileges:

  1. Press Windows Key + S, type cmd, right-click Command Prompt, and select Run as administrator.

  2. To defragment a traditional HDD (e.g., drive D:), run:

    defrag D: /U /V

    (The /U flag displays progress, and /V provides verbose output.)

  3. To execute the TRIM command on an SSD (e.g., drive C:), run:

    defrag C: /L

    (The /L flag tells the defrag utility to perform a re-trim.)

  4. To optimize all drives simultaneously based on their respective media types, run:

    defrag /C /O

Configuring Automatic Drive Optimization

Windows 11 includes an automatic scheduling feature that keeps drives optimized in the background:

  1. Open the Defragment and Optimize Drives utility.
  2. Under the Scheduled optimization section, check if scheduling is turned on.
  3. If it is disabled, click Turn on (or click Change settings to modify an existing schedule).
  4. Check the box labeled Run on a schedule (recommended).
  5. Set the frequency to Weekly or Monthly.
  6. Click Choose to select which drives are included in the automatic routine, then click OK to save your preferences.