check_for_optimal_dd_blocksize
Differences
This shows you the differences between two versions of the page.
check_for_optimal_dd_blocksize [2018/07/05 08:50] – created admin | check_for_optimal_dd_blocksize [2018/07/05 08:50] (current) – admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | < | ||
+ | #!/bin/bash | ||
+ | |||
+ | # Since we're dealing with dd, abort if any errors occur | ||
+ | set -e | ||
+ | |||
+ | TEST_FILE=${1: | ||
+ | [ -e " | ||
+ | TEST_FILE_SIZE=134217728 | ||
+ | |||
+ | # Header | ||
+ | PRINTF_FORMAT=" | ||
+ | printf " | ||
+ | |||
+ | # Block sizes of 512b 1K 2K 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M | ||
+ | for BLOCK_SIZE in 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 | ||
+ | do | ||
+ | # Calculate number of segments required to copy | ||
+ | COUNT=$(($TEST_FILE_SIZE / $BLOCK_SIZE)) | ||
+ | |||
+ | if [ $COUNT -le 0 ]; then | ||
+ | echo "Block size of $BLOCK_SIZE estimated to require $COUNT blocks, aborting further tests." | ||
+ | break | ||
+ | fi | ||
+ | |||
+ | # Create a test file with the specified block size | ||
+ | DD_RESULT=$(dd if=/ | ||
+ | |||
+ | # Extract the transfer rate from dd's STDERR output | ||
+ | TRANSFER_RATE=$(echo $DD_RESULT | \grep --only-matching -E ' | ||
+ | |||
+ | # Clean up the test file if we created one | ||
+ | [ $TEST_FILE_EXISTS -ne 0 ] && rm $TEST_FILE | ||
+ | |||
+ | # Output the result | ||
+ | printf " | ||
+ | done | ||
+ | |||
+ | </ | ||
+ | |||
credits go to: [[http:// | credits go to: [[http:// |
check_for_optimal_dd_blocksize.txt · Last modified: 2018/07/05 08:50 by admin