简体   繁体   English

如何模拟ext3文件系统损坏?

[英]How can I simulate ext3 filesystem corruption?

I would like to simulate filesystem corruption for the purpose of testing how our embedded systems react to it and ultimately have them fail as gracefully as possible. 我想模拟文件系统损坏,以便测试我们的嵌入式系统如何对它做出反应,并最终使它们尽可能优雅地失败。 We use different kinds of block device emulated flash storage for data which is modified often and unsuitable for storage in NAND/NOR. 我们使用不同类型的块设备模拟闪存存储器来经常修改并且不适合存储在NAND / NOR中的数据。

Since I have a pretty good idea of how often data is modified in different parts of the file tree and where sensitive data is stored. 因为我非常清楚在文件树的不同部分修改数据的频率以及存储敏感数据的位置。 I would like to inject errors in specific areas and not just randomly. 我想在特定区域注入错误,而不仅仅是随机。

In cases of emergency we use fsck -y as a sort of last resort in order to attempt to bring the system up and report that is in a very bad state. 在紧急情况下,我们使用fsck -y作为最后的手段,以便尝试启动系统并报告处于非常糟糕的状态。 I would very much like to cause errors which would trigger fsck to attempt repairs in order to study the effect on the systems capability to come back up. 我非常希望引发错误,这些错误会触发fsck尝试修复,以便研究对系统恢复能力的影响。

dd if=/dev/random is not precise enough for my purpose since it can't easily be used to inject controlled errors. dd if=/dev/random对于我的目的来说不够精确,因为它不能轻易用于注入受控错误。 Are there any other tools or methods which fit my needs better or do I have to invent my own? 还有其他工具或方法可以更好地满足我的需求,还是我必须创造自己的?

If you already know what to modify, dd can read a file containing the bytes you want to write, and you tell it where to write them. 如果您已经知道要修改的内容,那么dd可以读取包含您要写入的字节的文件,并告诉它在哪里编写它们。

To figure out where to write, debugfs from the e2fsprogs package could help you. 要找出写入的位置,e2fsprogs包中的debugfs可以帮助您。

It should be possible to use a Linux filesystem image fuzzer to cause corruption: 应该可以使用Linux文件系统映像模糊器来导致损坏:

or one of the Linux disk fault injection techniques (eg dm-flakey in corruption mode) described in https://unix.stackexchange.com/a/144200 . 或者在https://unix.stackexchange.com/a/144200中描述的Linux磁盘故障注入技术之一(例如,损坏模式中的dm-flakey)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM