Skip to main content
Version: 2.7.3

Simulate Disk Faults

This document describes how to use Chaosd to simulate disk faults. This feature helps you simulate disk read/write load (via dd) or disk fill (via dd or fallocate).

Before creating an experiment, you can run the following command to check the types of disk faults that are supported by Chaosd:

chaosd attack disk -h

Currently, Chaosd supports creating disk read load experiments, disk write load experiments, and disk fill experiments.

To create experiments using the service mode, you need to run Chaosd in the service mode and then send a POST HTTP request to the /api/attack/disk path of the Chaosd service:

chaosd server --port 31767
curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/json" -d '{fault-configuration}'

For the fault-configuration part in the above command, you need to configure it according to the fault types. For the corresponding parameters and examples, refer to the parameters of each fault type in the following sections.

info

When running an experiment, remember to record the UID of the experiment. When you want to end the experiment corresponding to the UID, you need to send a DELETE HTTP request to the /api/attack/{uid} path of the Chaosd service.

Simulate disk read load​

Parameters for simulating disk read load​

Configuration itemAbbreviationService mode fieldDescriptionTypeValue
action—actionActions of the experimentstringSet to "read-payload"
pathppathSpecifies the file path to read the data. If this parameter is not specified, or the parameter value is set to an empty string, Chaosd reads from the virtual disk files mounted in the "/" directory. Depending on the permissions to read the files, you might be required to run this program using certain permissions.stringDefault: ""
process-numnpayload-process-numSpecifies the number of concurrently running dd programs to be used.uint8Default: 1; range: 1 to 255
sizessizeSpecifies the volume of data to be read. It is the total size of data that dd reads.stringDefault: ""; required; legal form: the combination of an integer and a unit. For example, 1M, 512kB. Supported units are c=1, w=2, b=512, kB=1000, K=1024, MB=1000*1000, M=1024*1024, GB=1000*1000*1000, G=1024*1024*1024*1024 BYTE and so on.

Simulate disk read load using the command-line mode​

Simulating disk read load is a one-time operation, so the experiment does not need to be recovered.

Commands for simulating disk read load​

chaosd attack disk add-payload read -h

Example for simulating disk read load​

chaosd attack disk add-payload read -s 1000G -n 7 -p /dev/zero

Simulate disk read load using the service mode​

curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/json" -d '{"action":"read-payload","path":"/dev/zero", "payload-process-num":7,"size":"1000G"}'

Simulate disk write load​

Parameters for simulating disk write load​

Configuration itemAbbreviationService mode fieldDescriptionTypeValue
action—actionActions of the experimentstringSet to "write-payload"
pathppathSpecifies the file path to write the data. If this parameter is not specified, or the parameter value is set to an empty string, a temporary file will be created in the program execution directory. Depending on the permissions to write the files, you might be required to run this program using certain permissions.stringDefault: ""
process-numnpayload-process-numSpecifies the number of concurrently running dd programs to be used.uint8Default: 1; range: 1 to 255
sizessizeSpecifies the volume of data to be written. It is the total size of data that dd writes.stringDefault: ""; required; legal form: the combination of an integer and a unit. For example, 1M, 512kB. Supported units are c=1, w=2, b=512, kB=1000, K=1024, MB=1000*1000, M=1024*1024, GB=1000*1000*1000, G=1024*1024*1024*1024 BYTE and so on.

Simulate disk write load using the command-line mode​

Command for simulating disk write load​

chaosd attack disk add-payload write -h

Example for simulating disk write load​

chaosd attack disk add-payload write -s 2G -n 8

Simulate disk write load using the service mode​

curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/json" -d '{"action":"write-payload","path":"/tmp/test", "payload-process-num":7,"size":"1000G"}'

Simulate disk fill​

Parameters for simulating disk fill​

Configuration itemAbbreviationService mode fieldDescriptionTypeValue
action—actionActions of the experimentstringSet to "fill"
destroyddestroyIf this parameter is set to true, the fill file is immediately deleted after being filled.boolDefault: false
fallocateffill-by-fallocateIf this parameter is set to true, Linux is used to call fallocate to quickly apply for disk space and size must be greater than 0. If this parameter is set to false, Linux is used to call dd to fill disks at a relatively slow pace.boolDefault: true
pathppathSpecifies the file path to write the data. If this parameter is not specified, or the parameter value is set to an empty string, a temporary file will be created in the program execution directory. Depending on the permissions to write the files, you might be required to run this program using certain permissions.stringDefault: ""
percentcpercentSpecifies the percentage of disk size to be filled.stringDefault: ""; positive integer of the uint type is acceptable; you must set one of size or percent (both items cannot be "" at the same time).
sizessizeSpecifies the volume of data to be written.stringDefault: ""; legal form: the combination of an integer and a unit. For example, 1M, 512kB. Supported units are c=1, w=2, b=512, kB=1000, K=1024, MB=1000*1000, M=1024*1024, GB=1000*1000*1000, G=1024*1024*1024*1024 BYTE and so on. You must set one of size or percent (both items cannot be "" at the same time).

Simulate disk fill using the command-line mode​

Command for simulating disk fill​

chaosd attack disk fill -h

Example for simulating disk fill​

chaosd attack disk fill -c 50 -d

Simulate disk fill using the service mode​

curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/json" -d '{"action":"fill","path":"/tmp/test", "fill-by-fallocate":true,"percent":"50"}'