10 md=$(mdconfig -s40m) || exit 1
15 partszMB=$1 unitszMB=$2
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
25 kldload geom_eli >/dev/null 2>&1
27 setsize 10 40 || echo -n "not "
28 echo ok $i - "Sized ${md}a to 10m"
32 geli init -Bnone -PKtmp.key ${md}a || echo -n "not "
33 echo ok $i - "Initialised geli on ${md}a"
35 geli attach -pk tmp.key ${md}a || echo -n "not "
36 echo ok $i - "Attached ${md}a as ${md}a.eli"
39 newfs -U ${md}a.eli >/dev/null || echo -n "not "
40 echo ok $i - "Initialised the filesystem on ${md}a.eli"
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)) \
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.
52 geli backup ${md}a tmp.meta || echo -n "not "
53 echo ok $i - "Backed up ${md}a metadata"
56 geli detach ${md}a.eli || echo -n "not "
57 echo ok $i - "Detached ${md}a.eli"
60 setsize 20 40 || echo -n "not "
61 echo ok $i - "Sized ${md}a to 20m"
63 geli attach -pktmp.key ${md}a && echo -n "not "
64 echo ok $i - "Attaching ${md}a fails after resizing the consumer"
67 geli restore tmp.meta ${md}a && echo -n "not "
68 echo ok $i - "Restoring metadata on ${md}a.eli fails without -f"
70 geli restore -f tmp.meta ${md}a || echo -n "not "
71 echo ok $i - "Restoring metadata on ${md}a.eli can be forced"
74 geli attach -pktmp.key ${md}a || echo -n "not "
75 echo ok $i - "Attaching ${md}a is now possible"
78 growfs -y ${md}a.eli >/dev/null || echo -n "not "
79 echo ok $i - "Extended the filesystem on ${md}a.eli"
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)) \
89 # Now do the resize properly
91 geli detach ${md}a.eli || echo -n "not "
92 echo ok $i - "Detached ${md}a.eli"
95 setsize 30 40 || echo -n "not "
96 echo ok $i - "Sized ${md}a to 30m"
99 geli resize -s20m ${md}a || echo -n "not "
100 echo ok $i - "Resizing works ok"
102 geli resize -s20m ${md}a && echo -n "not "
103 echo ok $i - "Resizing doesn't work a 2nd time (no old metadata)"
106 geli attach -pktmp.key ${md}a || echo -n "not "
107 echo ok $i - "Attaching ${md}a works ok"
110 growfs -y ${md}a.eli >/dev/null || echo -n "not "
111 echo ok $i - "Extended the filesystem on ${md}a.eli"
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)) \
120 geli detach ${md}a.eli
123 # Verify that the man page example works, changing ada0 to $md,
124 # 1g to 20m, 2g to 30m and keyfile to tmp.key, and adding -B none
127 gpart create -s GPT $md || echo -n "not "
128 echo ok $i - "Installed a GPT on ${md}"
130 gpart add -s 20m -t freebsd-ufs -i 1 $md || echo -n "not "
131 echo ok $i - "Added a 20m partition in slot 1"
133 geli init -B none -K tmp.key -P ${md}p1 || echo -n "not "
134 echo ok $i - "Initialised geli on ${md}p1"
136 gpart resize -s 30m -i 1 $md || echo -n "not "
137 echo ok $i - "Resized partition ${md}p1 to 30m"
139 geli resize -s 20m ${md}p1 || echo -n "not "
140 echo ok $i - "Resized geli on ${md}p1 to 30m"
142 geli attach -k tmp.key -p ${md}p1 || echo -n "not "
143 echo ok $i - "Attached ${md}p1.eli"
146 geli detach ${md}p1.eli