How to

Fragment a hard disk.


Yes, you DID read right.


(Not proof read and tested for accuracy).

It is well known that Microsoft provide disk defragmentation tools in both Windows Desktop and Windows Server operating systems.

what is not known is how effective these tools are at increasing the effectiveness of your system.

We have an issue with a database server in that the backup files from its sister server,can take over two hours to copy across to the D: drive.

The fact that this disk is badly fragmented cannot help the issue.

To prove the worth of hard disk defragmentation, I set up a test system and deliberately fragmented the second hard disk (E:).

I then timed how long it would take to copy a file between C: and E: Repeating this five times to see how fast the transfer rate was.

I then moved all the files off the E: drive and returned them so they were in a defragmented state and re-ran the file copy test.

This document describes that process and the outcome.


The Process.

I created a folder on the PC’s C: drive called c:\zap\fragment_test. In this I stored the batch files and the specially created files used to fill the test hard disk.

The E: drive was a 4.3GB PATA hard disk that was sitting waiting to be binned. If I ‘cooked’ it, I wasn’t going to be too worried.

The theory behind the fragmentation is this: - Create a small file, in the case of this trial, the file was 16kb and was made out of a re-sized jpg file.

The file is then copied a multitude of times (see Annex A for the math) to create a ‘stack’, by using a batch file called ‘sixteen-stack.bat’, see Annex B.

This creates a series of directories, each containing a set of 16kb files, named from ‘sixteen-k.1 to sixteen-k.16’.

This created a 64MB directory called ‘sixteen-bulk’ which would then be copied to the E: drive multiple times, until the E: was full.

The copying was done by the batch file ‘copy-sixteen-stack.bat’, see Annex C.


Annex A.

Hard disk fragmentation Calculations.

Hard disk size: - 4.1GB

Cluster size: - 4kb


Number of 4kb clusters: - 4,100,000kb / 4kb = 1,025,000

Number of 16kb files required: - 1,025,000 / 4 = 256,250


Tier structure: - Each Lower Tier = 64 files = 64 files

Each Middle Tier = 16 Lower Tiers = 256 files

Each Upper Tier = 100 Middle Tiers = 25600 files

Each ‘Stack’ = 10 Upper Tiers = 256000 files


Annex B.

‘Sixteen-stack.bat’

@echo off

cls

md c:\zap\Fragment_Test\16-k\16-Bulk\Middle\Lower

pause

xcopy c:\zap\Fragment_Test\Sixteen-k.jpg c:\zap\Fragment_Test\16-k\16-Bulk\Middle\Lower\ /I

For /L %%a in (1,1,64) do xcopy c:\zap\Fragment_Test\16-k\16-Bulk\Middle\Lower\16-k.jpg c:\zap\Fragment_Test\16-k\16-Bulk\Middle\Lower\16-k.%%a

For /L %%b in (1,1,64) do xcopy c:\zap\Fragment_Test\16-k\16-Bulk\Middle\Lower\*.* /s c:\zap\Fragment_Test\16-k\16-Bulk\Middle\Lower%%b /I

For /L %%c in (1,1,10) do xcopy c:\zap\Fragment_Test\16-k\16-Bulk\Middle\*.* /s c:\zap\Fragment_Test\16-k\16-Bulk\Middle%%c /I


Annex C.

‘Copy-16-stack.bat’

@echo off

cls

md E:\Alpha\Level1\Level2\Level3

For /L %%a in (1, 1, 64) do xcopy c:\Zap\Fragment_Test\16-K\16-Bulk\*.* /s E:\Alpha\Level1%%a /I



Valid HTML 4.01 Transitional