0

Risk Factors for File Fragmentation include mostly full Disks and repeated file appends. What are other risk factors for file fragmentation? How would one make a program using common languages like C++/C#/VB/VB.NET to work with files & make new files with the goal of increasing file fragmentation?

WinXP / NTFS is the target

Edit: Would something like this be a good approach? Hard Drive free space = FreeMB_atStart

  • Would creating files of say 10MB to fill 90% of the remaining hard drive space
  • Deleting every 3rd created file
  • making file of size FreeMB_atStart * .92 / 3
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
ExcelCyclist
  • 115
  • 2
  • 2
  • 10

2 Answers2

3

This should achieve at least some level of fragmentation on most file systems:

  1. Write numerous small files,
  2. Delete some at random files,
  3. Writing a large file, byte-by-byte.

Writing it byte-by-byte is important, because otherwise if the file system is intelligent, it can just write the large file to a single contiguous place.

Abhijeet Kasurde
  • 3,937
  • 1
  • 24
  • 33
Paul Merrill
  • 580
  • 4
  • 14
  • So out using C++ and fstream be recommended for control? To write byte-by-byte, would you just use a outputFile.flush after each byte? – ExcelCyclist Feb 09 '10 at 04:55
  • Well, it would be much easier if you didn't use a buffered output stream in the first place. What about using putch()? – Paul Merrill Feb 09 '10 at 05:50
  • Still won't help. Too many operating systems just won't bother. Also, you can write 512 bytes at a time. No OS uses a smaller allocation unit anyway. – MSalters Feb 09 '10 at 09:35
0

Another possibility would be to write several files simultaneously byte-by-byte. This would probably have more effect.

Paul Merrill
  • 580
  • 4
  • 14