How can I simulate a failed disk during testing?

前端 未结 7 1940
情书的邮戳
情书的邮戳 2020-12-08 01:11

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 fai

7条回答
  •  遥遥无期
    2020-12-08 01:55

    To add to mark4o's answer, you can also use Linux's Device Mapper to generate failing devices.

    Device Mapper's delay device can be used to send read and write I/O of the same block to different underlying devices (it can also delay that I/O as its name suggests). Device Mapper's error device can be used to generate permanent errors when a particular block is accessed. By combining the two you can create a device where writes always fail but reads always succeed for a given area.

    The above is a more complicated example of what is described in the question Simulate a faulty block device with read errors? (see https://stackoverflow.com/a/1871029 for a simple Device Mapper example).

    There is also a list of Linux disk fault injection mechanisms on the Special File that causes I/O error Unix & Linux question.

提交回复
热议问题