How it works
JkDefrag is based on the standard defragmentation API by Microsoft, a system library that is included in Windows 2000, 2003, XP, Vista, and 2008. Most defragmenters are based on this API, including the free defragmenter that comes with Windows and many commercial defragmenters. Basically all JkDefrag does is send "move this file to that location" commands to the API. JkDefrag does not modify the disk by itself, and is therefore extremely solid.
Defragmentation and optimizing will not only make a harddisk faster, but also lengthen it's life span. The disk will have less work to do and therefore have less wear and tear. Secondly, the sorting optimization strategies (see the "-a" option) will refresh all the magnetic data on your harddisk. However, defragmenting and optimizing is work, so excessive defragmenting and optimizing can actually cause more wear and tear than it prevents. JkDefrag is therefore set for "fast" optimization by default, intended to be used on a daily basis. The other optimizations should only be used occasionally.
Phase 1: Analyze
JkDefrag has to scan all the files on the disk to determine if they are fragmented and where they are. A second step inside this phase will apply the exclude masks and determine which files are SpaceHogs.
Phase 2: Defragment
All fragmented files are defragmented, simply by moving them to the first gap on the disk that is big enough. If there is no gap big enough then the defragmenter will reduce the number of fragments in the file by moving as much of the file as possible into the largest gaps available.
Phase 3: Optimize
* On most harddisks the beginning of the harddisk is considerably faster than the end, sometimes by as much as 200 percent! See the link to "HD Tune" in the "See Also" chapter for a nice little free program to measure your disk. The default JkDefrag optimization strategy therefore moves all files to the beginning of the volume. It is intended for daily use and will simply fill gaps with files from above, very quick and with very little data movement.
* JkDefrag classifies files into 3 zones: directories (zone 1), regular files (zone 2), and SpaceHogs (zone 3). Directories are perhaps the most accessed data on disk, so zone 1 is placed at the beginning of the harddisk. After the directories comes a free area (see below), then zone 2 with regular files, another free area, and then zone 3 with SpaceHogs (less important files that take up a lot of space). The beginning and end of the zones is determined automatically, see the "-f" option.
* A running computer will create and delete temporary files like there is no tomorrow. If the harddisk were completely optimized then the only place for new temporary files would be behind all the other data. Which is rather slow. So JkDefrag maintains a free space of 1% of the total disk space between zone 1 (directories) and zone 2 (regular files), and between zone 2 and zone 3 (SpaceHogs).
* Sorting the files on your disk can give you even more speed. There are several sorting strategies to choose from (see the "-a" options). These are all very slow and intended for occasional use only.
* Windows reserves a percentage of the disk for the MFT (Master File Table), but can place normal files there if the rest of the disk is full. The files will remain there, even when there is enough space again. JkDefrag looks for files in the MFT reserved space and moves them to normal diskspace, making the reserved space available again for the MFT.
When JkDefrag is running you will see lot's of messages zipping by showing you exactly what is happening. The messages are also stored in the logfile ("JkDefrag.log" or "JkDefragCmd.log") for later inspection. The logfile may also contain warning messages, for example when a file could not be moved. This is normal, no need to worry. Windows has many system files that cannot be moved while Windows is running.
Commandline
JkDefrag is completely automatic.
The commandline options are not needed for normal use.
JkDefrag is ready to run, just click the "JkDefrag" program. Default behavior is to automatically process all the mounted, writable, fixed volumes on your computer. You can change this behavior with the following commandline options:
For example: JkDefrag.exe -a 7 -d 2 -q c: d:
-a N The action to perform. N is a number from 1 to 11, default is 3:
1 = Analyze, do not defragment and do not optimize.
2 = Defragment only, do not optimize.
3 = Defragment and fast optimize [recommended].
5 = Force together.
6 = Move to end of disk.
7 = Optimize by sorting all files by name (folder + filename).
8 = Optimize by sorting all files by size (smallest first).
9 = Optimize by sorting all files by last access (newest first).
10 = Optimize by sorting all files by last change (oldest first).
11 = Optimize by sorting all files by creation time (oldest first).
-e "mask" Exclude files and/or directories that match the mask. The items will not be defragmented and will not be moved. Use wildcards '*' and '?' in the mask to match a set of files or directories. If the mask contains a space then it must be enclosed in double-quotes. Some examples:
JkDefrag -e *.avi -e *.zip -e *.log
JkDefrag -e D:\MySQL\Data\*
-u "mask" Files that match a mask will be moved to the SpaceHogs area. The program has a built-in list for all files bigger than 50 megabytes, files not accessed in the last month, archives, files in the recycle bin, service pack files, and some others. Disable this list by specifying the special mask "DisableDefaults". Use wildcards '*' and '?' in the mask to match a set of files or directories. If the mask contains a space then it must be enclosed in double-quotes. Some examples:
JkDefrag -u *.avi -u *.zip -u *.log
JkDefrag -u D:\MySQL\Data\*
-s N Slow down to N percent (1...100) of normal speed. Default is 100.
-f N Set the size of the free spaces to N percent (0...100) of the size of the volume. The free spaces are room on disk for temporary files. There are 2 free spaces, between the 3 zones (directories, regular files, SpaceHogs). Default is 1% (per free space).
-d N Select a debug level, controlling the messages that will be written to the logfile. The number N is a value from 0 to 6, default is 1:
0 = Fatal errors.
1 = Warning messages [default].
2 = General progress messages.
3 = Detailed progress messages.
4 = Detailed file information.
5 = Detailed gap-filling messages.
6 = Detailed gap-finding messages.
-l "filename" Specify a filename for the logfile. Default is "JkDefrag.log" and "JkDefragCmd.log". Specify empty string "" (two double-quotes) to disable the logfile.
-h [commandline version only] Show a short help text.
-help [commandline version only] Show a short help text.
--help [commandline version only] Show a short help text.
/? [commandline version only] Show a short help text.
-q [windows version only] Quit the program when it has finished.
items The items to be defragmented and optimized, such as a file, directory, disk, mount point, or volume, including removable media such as floppies, USB disks, memory sticks, and other volumes that behave like a harddisk. Wildcards '*' and '?' are allowed to select a set of files. If the item contains a space then it must be enclosed in double-quotes. Some examples:
JkDefrag C: D:
JkDefrag f:\*.log D:\MySQL\Data\*
Fast optimization
This optimization strategy is designed for every day use. It moves a minimum of data on the harddisk and finishes very quickly, but will not fill all the gaps on the disk. The strategy scans for gaps on the disk and fills them with files from above.
Sorted optimization
All the sorting optimizations WILL CREATE FRAGMENTS. This is by design, it is not a bug. For more info see the Frequently Asked Questions.
These sorting optimizations are for incidental use once in a while. They take a lot of running time and data movement because they rewrite all the data on the disk. The strategies vacate a small area on disk and then fill it up again with the files in the selected order.
* Sort by name: very good for fast program starting. The files used by a particular program will be very close together on disk.
* Sort by size: placing all the small files together at the beginning of the disk will dramatically reduce the average file seek time.
* Sort by last access: files that have not been accessed in a while are probably unimportant and are best sorted to the back.
* Sort by last change: placing files together that change a lot (for example databases and log files) will speed up regular operation of the system.
* Sort by creation time: The oldest files on the disk are likely to be important system files, for example used when Windows is booting.
Note: If you want to sort by last access time then first make sure your virus scanner (and other programs that scan all files on disk) do not change that time.
Force together
Intended for partition resizing. All movable files are moved to the beginning of the disk, even if it means fragmenting them to fill gaps that cannot be filled otherwise.
Move to end of disk
Move all the files to the end of the disk, making more room at the beginning of the disk. Intended for big and rarely used files such as log files, backup archives, installation files, and such.
Bookmarks