模拟有读取错误的故障块设备? [英] Simulate a faulty block device with read errors?

查看:109
本文介绍了模拟有读取错误的故障块设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种更简便的方法来针对有缺陷的块设备测试我的应用程序,这些块设备在读取某些块时会产生I/O读取错误.尝试使用具有已知坏块的物理硬盘驱动器很痛苦,我想找到一种软件解决方案(如果存在).

I'm looking for an easier way to test my application against faulty block devices that generate i/o read errors when certain blocks are read. Trying to use a physical hard drive with known bad blocks is a pain and I would like to find a software solution if one exists.

我确实找到了 Linux磁盘故障模拟驱动程序,该驱动程序可以创建可以配置为在读取特定范围的块时生成错误,但这是针对2.4 Linux内核的,并且尚未针对2.6进行更新.

I did find the Linux Disk Failure Simulation Driver which allows creating an interface that can be configured to generate errors when certain ranges of blocks are read, but it is for the 2.4 Linux Kernel and hasn't been updated for 2.6.

最理想的是一个Lostup和循环驱动程序,该驱动程序还允许您将其配置为在尝试从给定的一组块读取时返回读取错误.

What would be perfect would be an losetup and loop driver that also allowed you to configure it to return read errors when attempting to read from a given set of blocks.

推荐答案

这不是您要查找的环回设备,而是设备映射器.

It's not a loopback device you're looking for, but rather device-mapper.

使用 dmsetup 创建由以下设备支持的设备错误"目标.它将显示在/dev/mapper/<name>.

设备映射器演示文稿(PDF)的第7页正是您所拥有的正在寻找:

Page 7 of the Device mapper presentation (PDF) has exactly what you're looking for:

dmsetup create bad_disk << EOF
  0 8       linear /dev/sdb1 0
  8 1       error
  9 204791 linear /dev/sdb1 9
EOF

或者忽略sdb1部分,并将错误"目标作为块0-8(而不是sdb1)的设备,以制作纯错误磁盘.

Or leave out the sdb1 parts to and put the "error" target as the device for blocks 0 - 8 (instead of sdb1) to make a pure error disk.

另请参见设备映射器来自"RHEL 5的附录 逻辑卷管理器管理".

See also The Device Mapper appendix from "RHEL 5 Logical Volume Manager Administration".

这篇关于模拟有读取错误的故障块设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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