1 # Copyright (c) 2012 Edward Tomasz NapieraĆa <trasz@FreeBSD.org>
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
7 # 1. Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # 2. Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
13 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 # This is a test for mdconfig(8) functionality. Run it as root:
30 # /usr/src/tools/regression/mdconfig/run /usr/src/tools/regression/mdconfig/mdconfig.test
32 # WARNING: Creates files in unsafe way.
44 # This awk thing is to strip the file path.
45 $ mdconfig -lv | awk '{ print $1, $2, $3 }'
48 $ diskinfo -v /dev/md0 | expand
51 > 1073741824 # mediasize in bytes (1.0G)
52 > 2097152 # mediasize in sectors
59 # Check different valid syntax variations: implicit -a.
64 $ mdconfig -lv | awk '{ print $1, $2, $3 }'
67 $ diskinfo -v /dev/md0 | expand
70 > 1073741824 # mediasize in bytes (1.0G)
71 > 2097152 # mediasize in sectors
80 $ mdconfig -a -t vnode -f xxx
83 $ mdconfig -lv | awk '{ print $1, $2, $3 }'
86 $ diskinfo -v /dev/md0 | expand
89 > 1073741824 # mediasize in bytes (1.0G)
90 > 2097152 # mediasize in sectors
97 # Size for vnodes - smaller than the actual file.
99 $ mdconfig -a -t vnode -f xxx -s 128m
102 $ mdconfig -lv | awk '{ print $1, $2, $3 }'
105 $ diskinfo -v /dev/md0 | expand
108 > 134217728 # mediasize in bytes (128M)
109 > 262144 # mediasize in sectors
116 # Size for vnodes - larger than the actual file.
118 $ mdconfig -a -t vnode -f xxx -s 128g
121 $ mdconfig -lv | awk '{ print $1, $2, $3 }'
124 $ diskinfo -v /dev/md0 | expand
127 > 137438953472 # mediasize in bytes (128G)
128 > 268435456 # mediasize in sectors
135 # Sector size for vnodes.
137 $ mdconfig -a -t vnode -f xxx -S 2048
140 $ mdconfig -lv | awk '{ print $1, $2, $3 }'
143 $ diskinfo -v /dev/md0 | expand
146 > 1073741824 # mediasize in bytes (1.0G)
147 > 524288 # mediasize in sectors
156 $ mdconfig -a -t malloc -s 1g
159 $ mdconfig -lv | awk '{ print $1, $2, $3 }'
162 $ diskinfo -v /dev/md0 | expand
165 > 1073741824 # mediasize in bytes (1.0G)
166 > 2097152 # mediasize in sectors
175 $ mdconfig -a -t swap -s 1g
178 $ mdconfig -lv | awk '{ print $1, $2, $3 }'
181 $ diskinfo -v /dev/md0 | expand
184 > 1073741824 # mediasize in bytes (1.0G)
185 > 2097152 # mediasize in sectors
192 # Attaching with a specific unit number.
194 $ mdconfig -as 1g -u 42
196 $ mdconfig -lv | awk '{ print $1, $2, $3 }'
199 $ diskinfo -v /dev/md42 | expand
202 > 1073741824 # mediasize in bytes (1.0G)
203 > 2097152 # mediasize in sectors
214 $ mdconfig -as 2g -u 42
216 $ mdconfig -lv | awk '{ print $1, $2, $3 }'
220 $ mdconfig -lvu 0 | awk '{ print $1, $2, $3 }'
223 $ mdconfig -lvu 42 | awk '{ print $1, $2, $3 }'
226 $ mdconfig -lvu 24 | awk '{ print $1, $2, $3 }'