Before disk defragment, you need to do something for preparation.
1. Make sure that the disk partition has at least 15% free space in order to complete a defragment of a disk partition. If the available space on the partition you want to defrag is less than 15%, it can only defrag only a part of fragments. You can delete some unnecessary files, move files to another partition or free up disk space to get more free space on the partition.
2. It is necessary to analyze the disk drive to see if it needs to be defragmented. If system reports that there is no need to defragment the drive, you had better not perform disk defragment.
To defragment disk partition with Command Prompt, you can follow the steps below:
Step1. Run Command Prompt on your computer with admin privileges
The methods to access command line are different on various Windows operating system.
Step2. Type defrag D: /o if you want to defrag D drive.
For example:
Note: /o means to optimize a disk partition.
Option: You may use defrag c: /a at first, and then defrag c: /o
Step1: defrag c: /a to analyze the c drive at first, and then it would tell whether it's recommend to start a defragment.
Step2: defrag c: /o to optmize a drive.
Type defrag /? or defrag.exe plus the appropriate parameters (e.g. defrag.exe c: /a) to analyze or defrag the partition you need to defragment.
You can type defrage.exe to show list of command line parameters, and then you can type a proper one based on your needs.
List of command line parameters:
Tip:
The c: in the list above refers to the C drive, you can replace c: with any drive letter
else on your computer.
Step1: Open Windows PowerShell as administrator, and type the following command to analyze your drive. Look at the bottom of the output, it will advise whether or not you need to defrag the drive.
Optimize-Volume -DriveLetter D -Analyze -Verbose
And it will tell you: It is recommended that you defragment this volume.
Step2: Defrag your drive with the following Powershell command
Optimize-Volume -DriveLetter D -Defrag -Verbose
Does defrag an SSD work?
Truth: SSD defragging can cause performance issues and even reduce the life of the SSD. You may use the trim command to erase unused blocks which are no longer in use:
Optimize-Volume -DriveLetter D -ReTrim -Verbose
If you run CMD to analyze the hard drive and it says there is no need to defragment the selected drive, you had better stop defragmenting it. You usually receive this message when type defrag.exe x: -a command to analyze the selected drive (x: refers to the partition you want to defrag)
If you receive this message, it means that there is no fragment on the partition. So you do not need to defragment this drive.
IM-Magic Partition Resizer is a free partition magic tool which enables you to defrag hard
disk with following two steps:
Step1. Right click the partition you want to defrag and select "Defragment" option.
Step2. Confirm to defrag the selected volume
==> If you want to look for some other methods to defrag hard disk, please go to this page – Free to defragment hard drive on Windows computer>>
For Windows 11/10/8/7/Vista/XP/2000 ==> Download IM-Magic Partition Resizer Free
For Windows Server All versions ==> Download IM-Magic Partition Resizer Server
There are different methods to defrag hard drive, while Command Prompt is one of them for disk defragment.
When a hard drive contains too many fragments, it could have influence on the performance of the hard disk and slow down your computer. Defragmenting is a process to analyze the disk partition and defragment fragments in order to recover some disk space and improve the performance of your disk. Since data is written randomly to different clusters on a hard disk, there is no way to avoid hard disk fragments. Therefore, it is necessary to regularly defrag hard disk in order to improve performance.