November 27th, 2007

When you compress a drive, some files are exempted, but you can force it, and then it's your problem

On the drive property sheet for an NTFS volume, there is a checkbox called “Compress drive to save disk space.” If you check that box, the shell marks the drive as “compress all newly-created files” and also goes through and compresses all the existing files on the drive. Well, almost all the file. Some files are exempted by default. Examples of exempted files are the files involved in booting the system (NTLDR, NTDETECT.COM, HIBERFIL.SYS) and files for which write requests must succeed (PAGEFILE.SYS). (If a file is compressed, then a write to previously-committed file data may fail if the new data does not compress as well as the old data and there is no more disk space.) These files are exempted on all drives, even if they’re not your system drive. On the other hand, if you right-click one of these exempted files and explicitly compress it, then the shell will compress it (or at least try to). For boot files, this will typically succeed since boot files are used only at boot; once the system is running, they aren’t needed any more and therefore there aren’t any open handles to the file with restrictive sharing modes. Of course, if you do this to your system drive, it won’t boot any more. So don’t do that.

Like with many things in the physical world, if you force it too hard, it may break.

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.