-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathddoptim.sh
More file actions
executable file
·70 lines (50 loc) · 1.03 KB
/
ddoptim.sh
File metadata and controls
executable file
·70 lines (50 loc) · 1.03 KB
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
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
trap 'sigint' INT
function sigint
{
term_error SIGINT
}
. ~root/proxies/includer.inc.sh argparser
function term_error
{
echo "$@" > /dev/stderr
exit 1
}
function io.readln
{
read -r
}
function io.writeln
{
echo "$*"
}
function verbose.printf
{
printf "$@" > /dev/stderr
}
function main
{
# Arguments with a default of 'false' do not take paramaters
ArgParser::addArg "if" "/dev/sda" "Drive or Partition to test"
ArgParser::addArg "[h]elp" false "This crus"
# declare -p __arglist
ArgParser::parse "$@"
ArgParser::isset help && ArgParser::showArgs && exit 0
# returns: 0 on success, 1 on failure
ArgParser::tryAndGetArg if into disk || term_error "No disk specified with --if"
start=1
current=1
stop=65536
size=65536
size=10240
stop=$size
while (( current < stop ))
do
(( count = size / current ))
echo -n "$current k: "
dd if=$disk of=/dev/null bs=${current}k count=$count
(( current *= 2 ))
# 419430400 bytes (419 MB) copied, 11.8132 s, 35.5 MB/s
done
}
main "$0" "$@" || exit 1