-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisk_setup.sh
More file actions
89 lines (71 loc) · 2.13 KB
/
disk_setup.sh
File metadata and controls
89 lines (71 loc) · 2.13 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
export PATH=$PATH:/root/bin
source ~/.profile
source $PWD/disk-setup/disk_func.sh
hdd=()
ssd=()
ssd_path=$1 #/var/0chain/blobber
hdd_path=$2 #/var/0chain/blobber
sudo apt install parted -y
# Pick sda type disk
for n in $(lsblk --noheadings --raw -o NAME | grep "sd" | cut -c 1-3 | sort | uniq -u); do
if [[ $(lsblk -o name,rota | grep $n | awk '{print $2}') == 1 ]]; then
# echo "inside sdd"
hdd+=("$n")
fi
if [[ $(lsblk -o name,rota | grep $n | awk '{print $2}') == 0 ]]; then
ssd+=("$n")
fi
done
# Pick nvme type disk
for n in $(lsblk --noheadings --raw -o NAME | grep "nvme" | cut -c 1-5 | sort | uniq -u); do
if [[ $(lsblk -o name,rota | grep $n | awk '{print $2}') == 1 ]]; then
# echo "inside nvm"
hdd+=("$n")
fi
if [[ $(lsblk -o name,rota | grep $n | awk '{print $2}') == 0 ]]; then
ssd+=("$n"n1)
fi
done
#Getting ssd type of disk into variable
for x in ${ssd[@]}; do
ssd_disk_type=$(echo ${x} | cut -b 1-2)
done
len_ssd=${#ssd[@]}
# Resolve the type of ssd disk type sda vs nvme
ssd_partition=()
ssd_partition+=(/dev/"$i"p1)
# echo "ssd_disk_type $ssd_disk_type"
# echo "disks ${ssd[@]}"
# echo "disks len $len_ssd"
# echo "disks partition ${ssd_partition[@]}"
single_ssd $ssd p1 $ssd_path $hdd_path
sudo mkdir -p $hdd_path
sudo mkdir -p $ssd_path
#Getting hdd type of disk into variable
for x in ${hdd[@]}; do
hdd_disk_type=$(echo ${x} | cut -b 1-2)
done
len_hdd=${#hdd[@]}
# Resolve the type of ssd disk type sda vs nvme
hdd_partition=()
if [[ $hdd_disk_type == "nv" ]]; then
for i in "${hdd[@]}"; do
hdd_partition+=(/dev/"$i"p1)
done
elif [[ $hdd_disk_type == "sd" ]]; then
for i in "${hdd[@]}"; do
hdd_partition+=(/dev/"$i"1)
done
else
echo ""
fi
# echo "ssd_disk_type $ssd_disk_type"
# echo "disks ${hdd[@]}"
# echo "disks len $len_ssd"
# echo "disks partition ${hdd_partition[@]}"
echo "Multiple hdd's of sd types are present"
multiple_hdd $hdd 1 $ssd_path $hdd_path $hdd_partition
echo "No additional ssd's are present"
sudo mkdir -p $hdd_path
sudo mkdir -p $ssd_path