Last active
August 29, 2015 14:17
-
-
Save tobert/02ccf4cd856fcce7bb8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script creates a 128MB loopback file + device then puts | |
# dm-delay in front of it to cause all IOs to take >= 500ms. | |
bytes=$((2**27)) # 134217728 or 128MB | |
blocks=$(($bytes / 512)) # 262144 | |
# create the loopback file | |
dd if=/dev/zero of=/srv/tmp.img bs=512 count=$(($blocks + 32)) | |
# create the loop device, --show makes it print the /dev | |
loop=$(losetup --find --show /srv/tmp.img) | |
# create the delay target device on top of the loop device | |
echo "0 $blocks delay $loop 0 500" | dmsetup create delay | |
# create an ext4 filesystem - it will be slow since IOs are 500ms | |
mkfs.ext4 /dev/mapper/delay # takes a while | |
mkdir -p /mnt/delay | |
mount /dev/mapper/delay /mnt/delay |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment