Disks Defragmentation

With Windows 7 you can defragment internal and external disk drives, USB drives and Virtual drives but they must be formatted with the NTFS file system and are not network shared (mapped) drives! By default, defragmentation happens automatically every Wednesday at 1:00 A.M. however, if the computer is off at this time, it will start shortly after the next boot up! Also, it detects all drives installed on your system and performs defragmentation on all drives. The cool thing about Windows 7 is that it recognizes SSD drives (solid state drives) too, and disables the defrag operation on them as they do not need it. Microsoft has tweaked the defragmentation algorithm to perform better :)

Disk fragmentation happens when files are created, deleted and modified over time with the result that if a file needs to increase its size and there is no room adjacent to it, it gets another portion of the disk somewhere else and hence, the file is now in two or more locations on the disk – the file is fragmented!  This is basically the behavior of fragmentation and is quite normal to happen on all systems, whereas, heavily used systems will experience higher fragmentation quicker. Highly fragmented file systems will slow down file access times and will put additional stress on the hard drive.

To start Disk Defragmenter type disk defragmenter in the Start search text box and press enter.

You can select any drive and click the Analyze disks button for the latest fragmentation state, however, the main window displays the status of the last run. It is recommended to defrag the disk if the number is above 10%. Remember that the operation on the system drive takes longer and it would slow down your system. Click the Defragment disks button to start the defrag operation. Disk Defragmenter might take long to complete, it depends on the size and degree of fragmentation of your hard disk. You can schedule regular disk defragmentation by clicking the Configure Schedule… button. If a disk is excluded from the schedule, it is not defragmented and you need to do it manually. Make sure that the Run on a schedule option is checked. Then, you can configure which disks to include in the operation and frequency, day and time of the schedule.

For the advanced users, there is a command-line defragmentation tool called defrag. From an elevated command prompt type defrag /? To see all options:

                defrag <volumes> | /C | /E <volumes>    [/H] [/M | [/U] [/V]]

                defrag <volumes> | /C | /E <volumes> /A [/H] [/M | [/U] [/V]]

                defrag <volumes> | /C | /E <volumes> /X [/H] [/M | [/U] [/V]]

                defrag <volume>                      /T [/H]       [/U] [/V]

/A – Perform analysis on the specified volumes

/C – Perform the operation on all volumes

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

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

/M – Run the operation on each volume in parallel in the background

/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, the command defrag /a /c /h /u analyzes all volumes and storage devices on your system, shows the progress in the command prompt window and runs at normal priority. You should avoid the /h option if performing other resource intensive operations at the same time. Also, defragmentation may fail to run if the Task Scheduler service is disabled or fail for a specific disk if that disk is in exclusive use by another program.