Intentionally corrupt the file system

I have to explicitly test the case what my application does if it tries to access some corrupted part of an NTFS file system. I looked around for similar questions but those were about corrupting specific files (ie destroy the syntax of an xml file, etc).

I need to create a scenario where chkdsk would report errors in the file system in a specific location.

Does anybody have any idea how I could provoke such a situation to test my application.

Just in case you worry: I wouldn't do that on my production system, I have a VM set up for things like that.


If the concern is about what your app would do when encountering corrupt files, then why bother corrupting the filesystem that contains the files? Why not simply corrupt the files themselves?

The operating system does a lot to ensure that filesystems are robust, I'm not sure that intentionally scribbling garbage on the file system will do anything other than fuzz test the filesystem implementation.


Since there is no better solution here, I did it the hard way: I used Sysinternals NTFSInfo to find the location of the Master File Table, started a Linux Live CD and edited some bits in both locations of the Master File Table (MFT). Took some time to figure out the right places, but I can produce a corrupted file system no to test the error routines in my application.

Thanks to those contributing ideas, but I will award the answer to myself. If anybody has the same problem in the future, feel free to contact me.


我会尝试在磁盘(或磁盘分区)的某些随机位置写入一些随机字节。

链接地址: http://www.djcxy.com/p/56472.html

上一篇: 在Oracle中使用oracle视图加载SQL?

下一篇: 有意破坏文件系统