diff options
Diffstat (limited to 'prep-benchmark-fs.sh')
-rwxr-xr-x | prep-benchmark-fs.sh | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/prep-benchmark-fs.sh b/prep-benchmark-fs.sh new file mode 100755 index 0000000..3a46946 --- /dev/null +++ b/prep-benchmark-fs.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +set -o nounset +set -o errexit +set -o errtrace +set -o pipefail + +while getopts "hd:m:f:" arg; do + case $arg in + h) + usage + exit 0 + ;; + d) + DEV=$OPTARG + ;; + m) + MNT=$OPTARG + ;; + f) + FS=$OPTARG + ;; + esac +done + +if [[ -z $DEV ]]; then + echo "Required parameter -d missing: device to test" + exit 1 +fi + +if [[ -z $MNT ]]; then + echo "Required parameter -m missing: mount point" + exit 1 +fi + +if [[ -z $FS ]]; then + echo "Required parameter -f missing: filesystem type" + exit 1 +fi + +umount $DEV >/dev/null 2>&1 || true +umount $MNT >/dev/null 2>&1 || true + +blkdiscard -s $DEV >/dev/null 2>&1 || + blkdiscard $DEV >/dev/null 2>&1 || + true + +case $FS in + bcache) + wipefs -a $DEV + bcache format \ + --error_action=panic \ + --data_csum_type=none \ + --cache $DEV + ;; + ext4) + mkfs.ext4 -F $DEV + ;; + ext4-no-journal) + mkfs.ext4 -F -O ^has_journal $DEV + ;; + xfs) + mkfs.xfs -f $DEV + ;; + btrfs) + mkfs.btrfs -f $DEV + ;; +esac + +mount $DEV $MNT |