如何在测试期间模拟故障磁盘? [英] How can I simulate a failed disk during testing?

查看:1551
本文介绍了如何在测试期间模拟故障磁盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux VM(Vmware工作站或类似工具)中,如何模拟以前工作的光盘上的故障?

In a Linux VM (Vmware workstation or similar), how can I simulate a failure on a previously working disc?

我在生产中发生了一种情况光盘出现故障(可能是控制器,电缆或固件问题)。显然这是不可预测或可重复的,我想测试我的监控以确保它正确警报。

I have a situation happening in production where a disc fails (probably a controller, cable or firmware problem). Obviously this is not predictable or reproducible, I want to test my monitoring to ensure that it alerts correctly.

我理想的是能够模拟它的情况写入失败但成功读取,以及完全失败,即scsi接口将错误报告给内核。

I'd ideally like to be able to simulate a situation where it fails writes but succeeds reads, as well as a complete failure, i.e. the scsi interface reports errors back to the kernel.

推荐答案

有几个层可以模拟磁盘错误。如果您正在测试单个用户空间程序,可能最简单的方法是插入适当的调用(例如 write())并让它们有时返回错误。 libfiu 故障注入库使用可以执行此操作 blitiri.com.ar/p/libfiu/doc/man-fiu-run.html\"rel =nofollow noreferrer> fiu-run 工具。

There are several layers at which a disk error can be simulated. If you are testing a single user-space program, probably the simplest approach is to interpose the appropriate calls (e.g. write()) and have them sometimes return an error. The libfiu fault-injection library can do this using its fiu-run tool.

另一种方法是使用可以向/从另一个设备传递数据的内核驱动程序,但是在此过程中注入错误。然后,您可以挂载设备并在任何应用程序中使用它,就像它是一个有故障的磁盘一样。 fsdisk 驱动程序就是一个例子。

Another approach is to use a kernel driver that can pass through data to/from another device, but inject faults along the way. You can then mount the device and use it from any application as if it was a faulty disk. The fsdisk driver is an example of this.

还有一个故障注入基础架构已合并到Linux内核中,尽管您可能需要重新配置内核才能启用它。它记录在文档/故障注入/故障注入中。 TXT 。这对于测试内核代码很有用。

There is also a fault injection infrastructure that has been merged in to the Linux kernel, although you will probably need to reconfigure your kernel to enable it. It is documented in Documentation/fault-injection/fault-injection.txt. This is useful for testing kernel code.

也可以使用 SystemTap 在内核级别注入错误。请参阅 SCSI故障注入测试使用SystemTap注入内核错误

It is also possible to use SystemTap to inject faults at the kernel level. See The SCSI fault injection test and Kernel Fault injection using SystemTap.

这篇关于如何在测试期间模拟故障磁盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆