Following on yesterdays blog post on A Faster Way To Defragment Your Hard Drive, I decided to blog on an easy way to fragment your hard drive – although, this is usually not what we intend to do.
After a while, our hard drives tend to fill up with (mostly junk), and we get a warning message from Windows that we are running low on space, would you like to run Disk Cleanup? And we say yes.
Aside from asking if we want to delete a bunch of temporary files, it also asks if it can compress old files (file we don’t use very much).
Compressing files or folders leads to increased file fragmentation – especially on a drive with low disk space.
This happens because compressed files and folders are packed into larger files to avoid space loss that occurs because of cluster size. A cluster is the smallest writable unit on a hard drive. On Windows, for hard drives bigger than 2GB, the cluster size is 4096 bytes. That means if your file is only 100 bytes long, it still occupies 4096 bytes on the disk. This means 40 files of size 100 bytes will occupy 163 840 bytes on the hard disk. When you use file or folder compression, those 40 files can be squeezed into a single cluster of 4096 bytes.
The reason fragmentation occurs when using compressed folders and files on drive with low disk space is:
- Windows creates large files to pack the smaller ones into
- Since disk space is low, Windows can’t find enough space to write the larger file in a contiguous manner
- So Windows writes the file in several fragments scattered all over the disk – wherever it can find space.
I do use compressed files and folders on my system, but I only use it for files that I rarely change. And, after compressing the files and folders, I defragment them.
Compressing files and folders is a good way to trade off the space used by them for a little extra time to access them – I don’t find the difference to be significant enough to worry about it – but it is important to be aware that fragmentation is a very real possibility and this fragmentation can significantly add to the file access time (not only does the OS have to decompress them on the fly, but it also has to scurry all over the disk finding the pieces of that file).