forked from RunzhouHan/ECFault
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvmbk_multi_disk_create.sh
executable file
·79 lines (57 loc) · 1.92 KB
/
nvmbk_multi_disk_create.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# This script creates NVMe TCP targets
# Need nvme-tcp kernel modules
modprobe nvme_tcp
modprobe nvmet
modprobe nvmet_tcp
me=$0
ECFAULT_HOME=$(cd -P -- `dirname $me`/ && pwd -P)
# Configuration #
dev=(sda sdb sdc sdd sde sdf sdg sdh sdj) # physical device name
dev_count=9
target_per_dev=1 # number of OSDs
target_sz=1024 # OSD size
conn="tcp" # connection type
addr_traddr="10.24.86.175" # target host ip addr
loop_idx=20 # start from /dev/loop20, modify per your loop device availability
mkdir -p $ECFAULT_HOME/img
curr=0
it=0
while [ $curr -lt $dev_count ]
do
mkdir -p $ECFAULT_HOME/img/${dev[curr]}
curr_count=0
while [ $curr_count -lt $target_per_dev ]
do
pv_name=`echo "osd.pv.$it"`
dd if=/dev/zero of=$ECFAULT_HOME/img/${dev[curr]}/$pv_name bs=1M count=$target_sz
sleep 2
#let "curr=$it + $loop_idx"
losetup /dev/loop$(($it+$loop_idx)) $ECFAULT_HOME/img/${dev[curr]}/$pv_name
sleep 1
mkdir -p /sys/kernel/config/nvmet/subsystems/nvmet-$it \
&& cd /sys/kernel/config/nvmet/subsystems/nvmet-$it
echo 1 | tee -a attr_allow_any_host > /dev/null
mkdir -p namespaces/$(($it+1)) && cd namespaces/$(($it+1))
echo -n /dev/loop$(($it+$loop_idx)) | tee -a device_path > /dev/null
echo 1 | tee -a enable > /dev/null
sleep 1
mkdir -p /sys/kernel/config/nvmet/ports/1 \
&& cd /sys/kernel/config/nvmet/ports/1
if [[ $it -eq 0 ]]; then
echo ipv4 | tee -a addr_adrfam > /dev/null
echo $conn | tee -a addr_trtype > /dev/null
echo $addr_traddr | tee -a addr_traddr > /dev/null
echo 4420 | tee -a addr_trsvcid > /dev/null
fi
$ECFAULT_HOME/symlink.py /sys/kernel/config/nvmet/subsystems/nvmet-$it /sys/kernel/config/nvmet/ports/1/subsystems/nvmet-$it
sleep 1
let "it+=1"
let "curr_count+=1"
echo "it = $it"
done
let "curr+=1"
echo "curr = $curr"
done
sync
$ECFAULT_HOME/nvmetcli/nvmetcli save $ECFAULT_HOME/nvmet-config/$conn-$target_per_dev-$target_sz.json