-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
raidcalc
executable file
·43 lines (36 loc) · 938 Bytes
/
raidcalc
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
#!/bin/bash
if [ "x$2" = "x" ]; then
echo "Syntax: $0 disks size"
exit 0
fi
# 0 1 5 6 10
#Read performance High Medium Low Low High
#Write Performance High Medium Low Low Medium
#Fault tolerance None 1 1 2 1/sub-array
echo "Total capacity $(echo "$1 * $2"|bc -l) (disks $1, amount $2)"
# no fault tolerance
echo "RAID0 $(echo "$1 * $2"|bc -l)"
# 1 disk may fail
if [ "x$1" = "x2" ]; then
echo "RAID1 $(echo "$2"|bc -l)"
else
echo "RAID1 only with 2 disks"
fi
# one disk may fail
if [ "$1" -gt 2 ]; then
echo "RAID5 $(echo "($2 * $1) * ($1 - 1) / $1"|bc)"
else
echo "RAID5 minimum 3 disks"
fi
# two disks may fail
if [ "$1" -gt 3 ]; then
echo "RAID6 $(echo "($2 * $1) * ($1 - 2) / $1"|bc)"
else
echo "RAID6 minimum 4 disks"
fi
# you figure
if [ "$1" -gt 3 ]; then
echo "RAID10 $(echo "($2 * $1) / 2"|bc)"
else
echo "RAID10 minimum 4 disks"
fi