A script to fragment a test file
Well, this post won't cover any actual test results and is not specific to SAN. But in the spirit of full disclosure, I've attached the script I used to control the fragmentation level of the test files mentioned in this series of posts. The script is written in Perl, but can be easily done in any language.
The script does not itself fragment any file. Rather, it fragments the entire disk drive into non-contiguous blocks, or fragments, of a given size. A file (such as a database file) created afterwards is then necessarily fragmented into these fragments.
It takes three parameters at the beginning of the script: (1) $DRIVE to specify which drive the test file will be placed, (2) $FRAGMENT_SIZE to specify the size of the fragments in bytes, and (3) $FREE_SIZE to specify how much free space you want to have after the script completes. So if you want to examine the behavior of a 10GB test file that is fragmented into 128KB fragments, you may want to specify $FREE_SIZE to be slightly bigger than 10GB.
The script begins by creating an empty directory tree with enough directories so that each directory will hold 200 files of the specified size. It then proceeds to create 200 files in each of these directories until the drive is completely filled up. Finally, it randomly deletes some of these files until the free space on the drive reaches the value specified by $FREE_SIZE.
Hope you find this script useful in case you'd like to check out the impact of file fragmentation yourself.