Running Windows disk defragmentation on boot in Windows 10

I was wondering if I can run defragmentation when system boots up?

You can use IObit Smart Defrag for this. It has an option to perform a "Boot Time Defrag":

IObit Smart Defrag is another free tool that is worth keeping on the disk drive. (Get the portable version.) This not only defragments files, but it also has a Boot Time Defrag.

enter image description here

This runs a defragmenter utility just after the PC is switched on and before Windows loads. Turn on all the tick box options and click Configure.

IObit Smart Defrag

Select the Only next boot option, click Apply and then OK. Reboot the computer to defrag the system files that are in use.

Source Defragment the disk after upgrading to Windows 10 for speed


You could do this manually at boot time via command prompt.

Running Defrag in Command Prompt at boot

  • Open a command prompt at boot.

  • In the command prompt, type diskpart, and press Enter.

  • In the command prompt , type list volume, and press Enter.

Important: Make note of the drive letter that you want to optimize. The drive letter for the drive will not always be the same at boot as it is in Windows.

  • In the command prompt, type exit , press Enter, and go to the step below:

To use the defrag tool, just enter defrag followed by the parameters you want to use. You can view the command’s help file by entering defrag /? .

Then to use defrag, just enter the following:

defrag [name of your drive] [parameter] [extra parameters]

Here are some commonly used defrag commands:

defrag C: / O

Note: Substitute C : in the command with the drive letter you want instead .

i.e

defrag /C /O

In this case the O parameter stands for Perform the proper optimization for each media type (You can customize the parameters to your liking).

References

  • How to Optimize and Defragment Drives in Windows 10

  • Dig Deeper in Windows Defrag via Command Prompt