如何减小 NTFS 中文件夹索引文件的大小?
我有一个 NTFS 文件夹,其中包含数万个文件。 我已删除该文件夹中的所有文件,保存 1。我运行 contig.exe 对该文件夹进行碎片整理,因此现在它仅包含 1 个片段。 然而,该文件夹的大小仍然是 8MB。 这意味着该指数存在很大差距。 这是为什么? 如果我删除该文件,索引的大小会自动变为零。 我的猜测是因为它被折叠到 MFT 中。 有没有办法让NTFS真正对索引文件进行碎片整理,根据文件内容进行碎片整理? 您知道任何 API 吗? Contig.exe 仅对物理文件进行碎片整理。
I have a folder in NTFS that contains tens of thousands of files. I've deleted all files in that folder, save 1. I ran contig.exe to defragment that folder so now it's in 1 fragment only. However, the size of that folder is still 8MB in size. This implies that there's a lot of gap in the index. Why is that? If I delete that one file, the size of the index automatically goes to zero. My guess is because it gets collapsed into the MFT. Is there any way to get NTFS to truly defragment the index file by defragmenting it based on the content of the file? Any API that you're aware of? Contig.exe only defragment the physical file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想这是 NTFS 与几乎所有其他 FS 一样的一种方式 - 它们似乎都不喜欢缩小目录。
因此,您应该应用一种涉及使用高级语言“BAT”的高科技方法:)
collapse.bat
I guess this is one way in which NTFS is just like almost every other FS - none of them seem to like shrinking directories.
So you should apply a high-tech method that involves using that advanced language, "BAT" :)
collapse.bat
索引中有松弛,但没有间隙。 我做出这样的区分是为了暗示技术上存在空间浪费,但 NTFS 并不需要解析 8MB 才能枚举/查询/任何索引。 它知道其树的根在哪里,并且它恰好有很多额外的分配剩余。 考虑到它毫无帮助,可能太详细了。
碎片化可能完全是一个单独的问题。
There is slack in the index, but not a gap. I make the distinction to imply that there is technically wasted space, but it's not like NTFS has to parse the 8MB in order to enumerate/query/whatever the index. It knows where the root of its tree is, and it just happens to have a lot of extra allocation leftover. Probably too detailed a response, given how unhelpful it is.
Fragmentation is likely a separate issue altogether.
看看这个问题的公认答案:NTFS 性能和大量文件和目录
作者提供了一些有关文件索引碎片的其他未记录的信息,这些信息是他在一次事件期间从 Microsoft 技术支持处收到的。 简而言之,DEFRAG 不会对文件夹索引进行碎片整理,只会对该文件夹中的文件进行碎片整理。 如果要对文件索引进行碎片整理,则必须使用 SysInternals 的 CONTIG 工具,该工具现在由 Microsoft 拥有和分发(免费)。 答案提供了 CONTIG 的链接。
Take a look at the accepted answer to this question: NTFS performance and large volumes of files and directories
The author provided some otherwise undocumented information about file index fragmentation, which he received from Microsoft Tech Support during an incident. The short version is, DEFRAG does not defragment the folder index, only the files in that folder. If you want to defragment the file index, you have to use SysInternals' CONTIG tool, which is now owned and distributed (free) by Microsoft. The answer gives a link to CONTIG.