Defrag Windows disks from the command line and access extra features


Defragmenting the hard drive in Windows PC used to be an important maintenance task, but it is less important than it used to be. However, there are still occasions when it can boost PC performance a bit.

Read Do You Still Need a Disk Defragmenter for Windows PCs in 2017? if you want an introduction to defragmenting hard drives in Windows. Here we look at how to do this from the command line, which offers more functionality but requires a bit more technical knowledge than running it from the Windows interface.

Should You Defragment the Hard Drive?

The answer is not yes or now, but maybe. If your computer has either an SSD (Solid State Disk) or a hybrid drive that is part SSD and part hard drive, it should not be defragmented.

Files become fragmented and literally broken into fragments over time. A file can be split into a hundred or more parts, each located in a different part of the hard drive.

On a mechanical hard drive with spinning platters inside and arms that move read/write heads in and out, it takes a very long time to find all the pieces of a fragmented file.

An SSD simply reads memory locations and it doesn’t matter which part of the memory is read, everything is read at the same speed. A file split into 100 fragments on an SSD can be read as quickly as if it were a fragment.

Automatic defragmentation

Windows automatically defragments the hard drive in the background every week when the computer is idle. However, there are situations where this may not be the case, which can lead to significant fragmentation.

The hard drive can become quite fragmented if you have a laptop and run it on battery a lot. The reason for this is that defragmenting the hard drive consumes a lot of power, so the task will be skipped when a laptop is on battery power.

If you charge the laptop, but do not turn it on and run it on AC power, the defragmentation will be postponed and postponed, and the number of fragments will increase.

Here’s a laptop that has been running almost exclusively on battery power for a few weeks and fragmentation is up to 46%. That’s a lot, and it’s usually worth defragmenting disks when they hit more than 10%.

Check the disk for fragmentation in Windows at the command prompt

You could plug in and turn on your laptop and leave it idle for an hour or two, or you could manually run the Windows defrag tool and force it to optimize the disk.

Defrag from the command line

Although there is a graphical tool to defragment the hard drive, there are more features in the command line version. Right-click the Start button in Windows 10 and select Command Prompt (Admin). In Windows 7, go to Start, All Programs, Accessories, right-click Command Prompt and run as administrator.

To get a report showing the level of fragmentation on the hard drive, type

defrag c: /a

the C: is the drive letter and the /a means check for fragmentation and display a report.

If you want to see a constantly updated status while the defragmentation runs, use /u. To get a detailed report with much more information about the status of the hard drive, use / v. Command line parameters can be used individually or combined as follows:

defrag c: /a /u /v

View a disk fragmentation report using Defrag from the command line

Normally, the defrag tool runs with low priority. This means that it runs slowly so as not to slow down any programs you may be using. You can use the like command to force defrag to run with normal priority for programs, which allows the job to complete in less time. Input:

defrag c: /h

Not only files are fragmented, but also the free space on the hard drive. This can slow down writing to disk as small blocks of free space are filled with a file as it is saved, causing fragmentation. It can also be a problem when you want to shrink a drive partition. Use the following command to consolidate all free space:

defrag c: /x

It is possible to defrag two drives at the same time, e.g. B. drive C: and drive D: by typing the / m Command line switches as follows:

defrag c: d: /m

If you want to see constantly updated status for defragmentation, use /u. These parameters can be used individually or combined as follows:

defrag c: d: /m /h /u

This command defragments the C: and D: drives at the same time (/ m) with normal priority (/H) and shows the progress (/u).

There are more command line switches and they can be displayed by typing defrag /? but they are mainly for special purposes.

See more new articles in category: GUIDES
Leave a comment