]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/regression/geom_eli/resize.t
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / tools / regression / geom_eli / resize.t
1 #! /bin/sh
2 #
3 # $FreeBSD$
4
5 echo 1..27
6
7 BLK=512
8 BLKS_PER_MB=2048
9
10 md=$(mdconfig -s40m) || exit 1
11 unit=${md#md}
12 i=1
13
14 setsize() {
15     partszMB=$1 unitszMB=$2
16
17     {
18         echo a: $(($partszMB * $BLKS_PER_MB)) 0 4.2BSD 1024 8192
19         echo c: $(($unitszMB * $BLKS_PER_MB)) 0 unused 0 0
20     } | disklabel -R $md /dev/stdin
21 }
22
23 # Initialise
24
25 kldload geom_eli >/dev/null 2>&1
26
27 setsize 10 40 || echo -n "not "
28 echo ok $i - "Sized ${md}a to 10m"
29 i=$((i + 1))
30
31 echo secret >tmp.key
32 geli init -Bnone -PKtmp.key ${md}a || echo -n "not "
33 echo ok $i - "Initialised geli on ${md}a"
34 i=$((i + 1))
35 geli attach -pk tmp.key ${md}a || echo -n "not "
36 echo ok $i - "Attached ${md}a as ${md}a.eli"
37 i=$((i + 1))
38
39 newfs -U ${md}a.eli >/dev/null || echo -n "not "
40 echo ok $i - "Initialised the filesystem on ${md}a.eli"
41 i=$((i + 1))
42 out=$(fsck -tufs -y ${md}a.eli)
43 echo "$out" | fgrep -q MODIFIED && echo -n "not "
44 echo ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \
45     "lines of output"
46 i=$((i + 1))
47
48
49 # Doing a backup, resize & restore must be forced (with -f) as geli
50 # verifies that the provider size in the metadata matches the consumer.
51
52 geli backup ${md}a tmp.meta || echo -n "not "
53 echo ok $i - "Backed up ${md}a metadata"
54 i=$((i + 1))
55
56 geli detach ${md}a.eli || echo -n "not "
57 echo ok $i - "Detached ${md}a.eli"
58 i=$((i + 1))
59
60 setsize 20 40 || echo -n "not "
61 echo ok $i - "Sized ${md}a to 20m"
62 i=$((i + 1))
63 geli attach -pktmp.key ${md}a && echo -n "not "
64 echo ok $i - "Attaching ${md}a fails after resizing the consumer"
65 i=$((i + 1))
66
67 geli restore tmp.meta ${md}a && echo -n "not "
68 echo ok $i - "Restoring metadata on ${md}a.eli fails without -f"
69 i=$((i + 1))
70 geli restore -f tmp.meta ${md}a || echo -n "not "
71 echo ok $i - "Restoring metadata on ${md}a.eli can be forced"
72 i=$((i + 1))
73
74 geli attach -pktmp.key ${md}a || echo -n "not "
75 echo ok $i - "Attaching ${md}a is now possible"
76 i=$((i + 1))
77
78 growfs -y ${md}a.eli >/dev/null || echo -n "not "
79 echo ok $i - "Extended the filesystem on ${md}a.eli"
80 i=$((i + 1))
81
82 out=$(fsck -tufs -y ${md}a.eli)
83 echo "$out" | fgrep -q MODIFIED && echo -n "not "
84 echo ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \
85     "lines of output"
86 i=$((i + 1))
87
88
89 # Now do the resize properly
90
91 geli detach ${md}a.eli || echo -n "not "
92 echo ok $i - "Detached ${md}a.eli"
93 i=$((i + 1))
94
95 setsize 30 40 || echo -n "not "
96 echo ok $i - "Sized ${md}a to 30m"
97 i=$((i + 1))
98
99 geli resize -s20m ${md}a || echo -n "not "
100 echo ok $i - "Resizing works ok"
101 i=$((i + 1))
102 geli resize -s20m ${md}a && echo -n "not "
103 echo ok $i - "Resizing doesn't work a 2nd time (no old metadata)"
104 i=$((i + 1))
105
106 geli attach -pktmp.key ${md}a || echo -n "not "
107 echo ok $i - "Attaching ${md}a works ok"
108 i=$((i + 1))
109
110 growfs -y ${md}a.eli >/dev/null || echo -n "not "
111 echo ok $i - "Extended the filesystem on ${md}a.eli"
112 i=$((i + 1))
113
114 out=$(fsck -tufs -y ${md}a.eli)
115 echo "$out" | fgrep -q MODIFIED && echo -n "not "
116 echo ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \
117     "lines of output"
118 i=$((i + 1))
119
120 geli detach ${md}a.eli
121 gpart destroy -F $md >/dev/null
122
123
124 # Verify that the man page example works, changing ada0 to $md,
125 # 1g to 20m, 2g to 30m and keyfile to tmp.key, and adding -B none
126 # to geli init.
127
128 gpart create -s GPT $md || echo -n "not "
129 echo ok $i - "Installed a GPT on ${md}"
130 i=$((i + 1))
131 gpart add -s 20m -t freebsd-ufs -i 1 $md || echo -n "not "
132 echo ok $i - "Added a 20m partition in slot 1"
133 i=$((i + 1))
134 geli init -B none -K tmp.key -P ${md}p1 || echo -n "not "
135 echo ok $i - "Initialised geli on ${md}p1"
136 i=$((i + 1))
137 gpart resize -s 30m -i 1 $md || echo -n "not "
138 echo ok $i - "Resized partition ${md}p1 to 30m"
139 i=$((i + 1))
140 geli resize -s 20m ${md}p1 || echo -n "not "
141 echo ok $i - "Resized geli on ${md}p1 to 30m"
142 i=$((i + 1))
143 geli attach -k tmp.key -p ${md}p1 || echo -n "not "
144 echo ok $i - "Attached ${md}p1.eli"
145 i=$((i + 1))
146
147 geli detach ${md}p1.eli
148 mdconfig -du$unit
149
150 rm tmp.*