7 keyfile1
=`mktemp /tmp/$base.XXXXXX` ||
exit 1
8 keyfile2
=`mktemp /tmp/$base.XXXXXX` ||
exit 1
9 keyfile3
=`mktemp /tmp/$base.XXXXXX` ||
exit 1
10 keyfile4
=`mktemp /tmp/$base.XXXXXX` ||
exit 1
11 mdconfig
-a -t malloc
-s `expr $sectors + 1` -u $no ||
exit 1
15 dd if=/dev
/random of
=${keyfile1} bs
=512 count
=16 >/dev
/null
2>&1
16 dd if=/dev
/random of
=${keyfile2} bs
=512 count
=16 >/dev
/null
2>&1
17 dd if=/dev
/random of
=${keyfile3} bs
=512 count
=16 >/dev
/null
2>&1
18 dd if=/dev
/random of
=${keyfile4} bs
=512 count
=16 >/dev
/null
2>&1
20 geli init
-B none
-P -K $keyfile1 md
${no}
21 geli attach
-p -k $keyfile1 md
${no}
22 geli setkey
-n 1 -P -K $keyfile2 md
${no}
24 # Remove key 0 for attached provider.
25 geli delkey
-n 0 md
${no}
33 # We cannot use keyfile1 anymore.
34 geli attach
-p -k $keyfile1 md
${no} 2>/dev
/null
42 geli attach
-p -k $keyfile2 md
${no}
49 # We cannot remove last key without -f option (for attached provider).
50 geli delkey
-n 1 md
${no} 2>/dev
/null
57 # Remove last key for attached provider.
58 geli delkey
-f -n 1 md
${no}
65 # If there are no valid keys, but provider is attached, we can save situation.
66 geli setkey
-n 0 -P -K $keyfile3 md
${no}
74 # We cannot use keyfile2 anymore.
75 geli attach
-p -k $keyfile2 md
${no} 2>/dev
/null
83 geli attach
-p -k $keyfile3 md
${no}
91 geli setkey
-n 1 -P -K $keyfile4 md
${no}
99 # Remove key 1 for detached provider.
100 geli delkey
-n 1 md
${no}
101 if [ $?
-eq 0 ]; then
107 # We cannot use keyfile4 anymore.
108 geli attach
-p -k $keyfile4 md
${no} 2>/dev
/null
109 if [ $?
-ne 0 ]; then
115 # We cannot remove last key without -f option (for detached provider).
116 geli delkey
-n 0 md
${no} 2>/dev
/null
117 if [ $?
-ne 0 ]; then
123 # Remove last key for detached provider.
124 geli delkey
-f -n 0 md
${no}
125 if [ $?
-eq 0 ]; then
131 # We cannot use keyfile3 anymore.
132 geli attach
-p -k $keyfile3 md
${no} 2>/dev
/null
133 if [ $?
-ne 0 ]; then
140 rm -f $keyfile1 $keyfile2 $keyfile3 $keyfile4