#!/bin/bash # Set location to create test disk images IMAGE_PATH=/mnt/sdb # Do not edit # $1 = disk path, $2 = allocation, $3 = size in GB, $4 = cluster size diskTest(){ echo "Creating disk... prealloc: $2, cluster: $4, size: $3G" echo "qemu-img create -f qcow2 -o preallocation=$2 -o cluster_size=$4 -o size=$3G $N" N=$1/prealloc_$2_cluster_$4_size_$3g.qcow2 qemu-img create -f qcow2 -o preallocation=$2 -o cluster_size=$4 -o size=$3G $N } # Ensure nbd devices are present modprobe nbd max_part=8 # metadata test first echo "########################################################################################" diskTest $IMAGE_PATH "off" "4" "65536" qemu-nbd --connect=/dev/nbd0 $N dd if=/dev/urandom of=/dev/nbd0 bs=128M count=1 conv=fdatasync qemu-nbd --disconnect /dev/nbd0 echo echo "########################################################################################" time diskTest $IMAGE_PATH "metadata" "4" "65536" qemu-nbd --connect=/dev/nbd0 $N dd if=/dev/urandom of=/dev/nbd0 bs=128M count=1 conv=fdatasync qemu-nbd --disconnect /dev/nbd0 echo echo "########################################################################################" time diskTest $IMAGE_PATH "falloc" "4" "65536" qemu-nbd --connect=/dev/nbd0 $N dd if=/dev/urandom of=/dev/nbd0 bs=128M count=1 conv=fdatasync qemu-nbd --disconnect /dev/nbd0 echo echo "########################################################################################" time diskTest $IMAGE_PATH "full" "4" "65536" qemu-nbd --connect=/dev/nbd0 $N dd if=/dev/urandom of=/dev/nbd0 bs=128M count=1 conv=fdatasync qemu-nbd --disconnect /dev/nbd0