1 |
#!/bin/sh -e |
2 |
|
3 |
pool=workshop |
4 |
|
5 |
instance=koha.ffzg.hr |
6 |
size=60G |
7 |
instance=prod.vbz.ffzg.hr |
8 |
instance=bookreader.rot13.org |
9 |
|
10 |
if [ -z "$1" ] ; then |
11 |
zfs list -r $pool/block |
12 |
echo |
13 |
test -e "/mnt/*" && df -h /mnt/* | grep -v aufs |
14 |
echo |
15 |
du -hcs /$pool/ganeti/export/* | cut -d/ -f1,5 |
16 |
exit 1 |
17 |
else |
18 |
instance=$1 |
19 |
fi |
20 |
|
21 |
umount /mnt/$instance || true |
22 |
zfs destroy $pool/block/$instance || true |
23 |
|
24 |
zfs create -V $size -b 4k -s $pool/block/$instance |
25 |
|
26 |
test -d /mnt/$instance || mkdir /mnt/$instance |
27 |
|
28 |
wait_for() { |
29 |
echo -n "waiting for $1 " |
30 |
while [ ! -e $1 ] ; do |
31 |
echo -n . |
32 |
sleep 1 |
33 |
done |
34 |
echo " found" |
35 |
} |
36 |
|
37 |
wait_for /dev/zvol/$pool/block/$instance |
38 |
|
39 |
label=`echo $instance | cut -d. -f1` |
40 |
echo "label $label = $instance" |
41 |
|
42 |
time mkfs.ext4 -m 0 -L $label /dev/zvol/$pool/block/$instance |
43 |
|
44 |
wait_for /dev/disk/by-label/$label |
45 |
|
46 |
mount /dev/disk/by-label/$label /mnt/$instance/ |
47 |
cd /mnt/$instance/ |
48 |
dump=`ls /$pool/ganeti/export/$instance/*.disk0*.snap` |
49 |
ls -alh $dump |
50 |
zpool iostat 2 | tee /dev/shm/$instance & |
51 |
pid_iostat=$! |
52 |
( while true; do zfs list $pool/block/$instance ; sleep 10 ; done ) & |
53 |
pid_list=$! |
54 |
time restore rf $dump |
55 |
kill $pid_iostat |
56 |
kill $pid_list |
57 |
|
58 |
wc -l /dev/shm/$instance |
59 |
df -h /mnt/$instance |