-
Notifications
You must be signed in to change notification settings - Fork 6
/
dd_optimal_block_size_test.sh
executable file
·62 lines (52 loc) · 1.52 KB
/
dd_optimal_block_size_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
#
# Author :Julio Sanz
# Website :www.elarraydejota.com
# Email :[email protected]
# Tested in :Debian Wheezy/Jessie, CentOS 7/6
# Description :Script to check the optimal block size for a given device, useful to test with external drives
# Dependencies :None
# Usage :./dd_optimal_block_size_test.sh
# License :GPLv3
#
#
# VARIABLES
#
# Add as many as you want
blocks_to_check="1k 2k 4k 8k 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M"
# A temporary test file
test_file="/var/tmp/test_file"
# CAUTION!!! Check this variable output_destination carefully, dd will overwrite
# content of the device set as output_destination during this test
output_destination="/dev/sdc"
# To determine the size of the test file
count_n=128000
#
# FUNCTIONS
#
block_size_test(){
# Create test file
dd if=/dev/zero of=$test_file count=$count_n > /dev/null 2>&1
echo "---------Begin block size test----------"
for block_size in $blocks_to_check
do
result=`dd if=$test_file of=$output_destination bs=$block_size 2>&1 1>/dev/null`
time_spent=`echo $result | cut -d "," -f2`
speed=`echo $result | cut -d "," -f3`
echo "Block Size $block_size --- It took $time_spent --- Speed $speed"
done
# Remove test file
rm $test_file
}
how_to_use(){
echo "This script is intended to work without parameters"
echo "Just launch it -> ./dd_optimal_block_size_test.sh"
}
#
# MAIN
#
if [ $# -ne 0 ];then
how_to_use
else
block_size_test
fi