blob: 89f66e73a830fe018c46513eb815a94fbd600c47 (
plain)
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
|
#!/bin/bash
#
# Four disk Raid-0 DM in a single Raid-0 Configuration
#
PVCREATE=${PVCREATE:-/sbin/pvcreate}
PVREMOVE=${PVREMOVE:-/sbin/pvremove}
PVDEVICES=${PVDEVICES:-"/dev/sd[abcd]"}
VGCREATE=${VGCREATE:-/sbin/vgcreate}
VGREMOVE=${VGREMOVE:-/sbin/vgremove}
VGNAME=${VGNAME:-"vg_tank"}
LVCREATE=${LVCREATE:-/sbin/lvcreate}
LVREMOVE=${LVREMOVE:-/sbin/lvremove}
LVNAME=${LVNAME:-"lv_tank"}
LVSTRIPES=${LVSTRIPES:-4}
LVSIZE=${LVSIZE:-32G}
DEVICES="/dev/${VGNAME}/${LVNAME}"
zpool_dm_destroy() {
msg ${LVREMOVE} -f ${VGNAME}/${LVNAME}
${LVREMOVE} -f ${VGNAME}/${LVNAME} >/dev/null
msg ${VGREMOVE} -f ${VGNAME}
${VGREMOVE} -f ${VGNAME} >/dev/null
msg ${PVREMOVE} ${PVDEVICES}
${PVREMOVE} ${PVDEVICES} >/dev/null
}
zpool_create() {
# Remove EFI labels which cause pvcreate failure
for DEVICE in ${PVDEVICES}; do
dd if=/dev/urandom of=${DEVICE} bs=1k count=32 &>/dev/null
done
msg ${PVCREATE} -f ${PVDEVICES}
${PVCREATE} -f ${PVDEVICES} >/dev/null || exit 1
msg ${VGCREATE} ${VGNAME} ${PVDEVICES}
${VGCREATE} ${VGNAME} ${PVDEVICES} >/dev/null || exit 2
msg ${LVCREATE} --size=${LVSIZE} --stripes=${LVSTRIPES} \
--name=${LVNAME} ${VGNAME}
${LVCREATE} --size=${LVSIZE} --stripes=${LVSTRIPES} \
--name=${LVNAME} ${VGNAME} >/dev/null || exit 3
msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES}
${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} \
${DEVICES} || (zpool_dm_destroy && exit 4)
}
zpool_destroy() {
msg ${ZPOOL} destroy ${ZPOOL_NAME}
${ZPOOL} destroy ${ZPOOL_NAME}
zpool_dm_destroy
}
|