如何实现磁盘碎片整理器?

发布于 2024-07-15 22:23:13 字数 200 浏览 10 评论 0原文

我有一些想法想在磁盘碎片整理竞技场中尝试。 我得出的结论是,作为实施的先驱,能够将磁盘置于碎片状态将是有用的。 在我看来,这是一种比碎片整理更难实现的状态。 我认为商业碎片整理公司可能已经解决了这个问题。

所以我的问题......

如何实现分段器? 在使用它来测试碎片整理程序的上下文中什么有意义?

I have a few ideas I would like to try out in the Disk Defragmentation Arena. I came to the conclusion that as a precursor to the implementation, it would be useful, to be able to put a disk into a state where it was fragmented. This seems to me to be a state that is more difficult to achieve than a defragmented one. I would assume that the commercial defragmenter companies probably have solved this issue.

So my question.....

How might one go about implementing a fragmenter? What makes sense in the context that it would be used, to test a defragmenter?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

好久不见√ 2024-07-22 22:23:14

也许您不应该对实际磁盘进行碎片整理,而应该在模拟/模拟磁盘上测试碎片整理算法? 只有当您对算法本身按指定方式工作感到满意后,您才可以使用实际磁盘 API 在实际磁盘上进行测试。

您甚至可以拍摄实际碎片磁盘(您的或您认识的人的)的快照,并将此数据用作测试的模拟模型。

Maybe instead of fragmenting the actual disk, you should really test your defragmentation algorithm on a simulation/mock disk? Only once you're satisfied the algorithm itself works as specified, you could do the testing on actual disks using the actual disk API.

You could even take snapshots of actual fragmented disks (yours or of someone you know) and use this data as a mock model for testing.

从﹋此江山别 2024-07-22 22:23:14

如何最好地进行分段取决于文件系统。

一般来说,同时打开大量文件。 打开文件将创建一个新的目录条目,但不会导致为该文件写入块。 但现在依次检查每个文件,写入一个块。 这通常会导致下一个空闲块被消耗,从而导致所有文件相互碎片化。

现有文件进行碎片处理是另一回事。 基本上,执行相同的操作,但在现有文件的文件副本上执行此操作,删除原始文件并重命名副本。

How you can best fragement depends on the file system.

In general, concurrently open a large number of files. Opening a file will create a new directory entry but won't cause a block to be written for that file. But now go through each file in turn, writing one block. This typically will cause the next free block to be consumed, which will lead to all your files being fragmented with regard to each other.

Fragmenting existing files is another matter. Basically, do the same, but do it on a file copy of existing files, doing a delete of the original and rename of copy.

£冰雨忧蓝° 2024-07-22 22:23:14

我在这里可能过于简单化,但如果您人为地对磁盘进行碎片化,您运行的任何测试都将仅适用于由您的碎片生成器创建的碎片,而不适用于任何现实世界的碎片。 您最终可能会针对碎片工具中不代表现实世界发生情况的假设进行优化。

获取一些碎片磁盘的磁盘映像不是更容易、更准确吗? 您是否有任何朋友或同事相信您不会利用他们的数据做任何反社会的事情?

I may be oversimplifying here but if you artificially fragment the disk won't any tests you run will be only true for the fragmentation created by your fragmenter rather than any real world fragmentation. You may end up optimising for assumptions in the fragmenter tool that don't represent real world occurrences.

Wouldn't it be easier and more accurate to take some disk images of fragmented disks? Do you have any friends or colleagues who trust you not to do anything anti-social with their data?

乖乖公主 2024-07-22 22:23:14

碎片是一个数学问题,您在执行特定操作时试图最大化硬盘驱动器磁头移动的距离。 因此,为了有效地分段某些内容,您需要首先定义具体操作

Fragmentation is a mathematical problem such that you are trying to maximize the distance the head of the hard drive is traveling while performing a specific operation. So in order to effectively fragment something you need to define the specific operation first

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文