mirror of
https://github.com/opnsense/src.git
synced 2026-04-23 23:28:37 -04:00
231 lines
5.7 KiB
Text
231 lines
5.7 KiB
Text
# Copyright (c) 2012 Edward Tomasz Napierała <trasz@FreeBSD.org>
|
|
# All rights reserved.
|
|
#
|
|
# Redistribution and use in source and binary forms, with or without
|
|
# modification, are permitted provided that the following conditions
|
|
# are met:
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
# notice, this list of conditions and the following disclaimer.
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
# documentation and/or other materials provided with the distribution.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
# SUCH DAMAGE.
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# This is a test for mdconfig(8) functionality. Run it as root:
|
|
#
|
|
# /usr/src/tools/regression/mdconfig/run /usr/src/tools/regression/mdconfig/mdconfig.test
|
|
#
|
|
# WARNING: Creates files in unsafe way.
|
|
|
|
$ whoami
|
|
> root
|
|
$ umask 022
|
|
$ truncate -s 1gb xxx
|
|
|
|
$ mdconfig -l
|
|
|
|
$ mdconfig -af xxx
|
|
> md0
|
|
|
|
# This awk thing is to strip the file path.
|
|
$ mdconfig -lv | awk '{ print $1, $2, $3 }'
|
|
> md0 vnode 1024M
|
|
|
|
$ diskinfo -v /dev/md0 | expand
|
|
> /dev/md0
|
|
> 512 # sectorsize
|
|
> 1073741824 # mediasize in bytes (1.0G)
|
|
> 2097152 # mediasize in sectors
|
|
> 0 # stripesize
|
|
> 0 # stripeoffset
|
|
>
|
|
|
|
$ mdconfig -du 0
|
|
|
|
# Check different valid syntax variations: implicit -a.
|
|
|
|
$ mdconfig xxx
|
|
> md0
|
|
|
|
$ mdconfig -lv | awk '{ print $1, $2, $3 }'
|
|
> md0 vnode 1024M
|
|
|
|
$ diskinfo -v /dev/md0 | expand
|
|
> /dev/md0
|
|
> 512 # sectorsize
|
|
> 1073741824 # mediasize in bytes (1.0G)
|
|
> 2097152 # mediasize in sectors
|
|
> 0 # stripesize
|
|
> 0 # stripeoffset
|
|
>
|
|
|
|
$ mdconfig -du 0
|
|
|
|
# Explicit -t vnode.
|
|
|
|
$ mdconfig -a -t vnode -f xxx
|
|
> md0
|
|
|
|
$ mdconfig -lv | awk '{ print $1, $2, $3 }'
|
|
> md0 vnode 1024M
|
|
|
|
$ diskinfo -v /dev/md0 | expand
|
|
> /dev/md0
|
|
> 512 # sectorsize
|
|
> 1073741824 # mediasize in bytes (1.0G)
|
|
> 2097152 # mediasize in sectors
|
|
> 0 # stripesize
|
|
> 0 # stripeoffset
|
|
>
|
|
|
|
$ mdconfig -du 0
|
|
|
|
# Size for vnodes - smaller than the actual file.
|
|
|
|
$ mdconfig -a -t vnode -f xxx -s 128m
|
|
> md0
|
|
|
|
$ mdconfig -lv | awk '{ print $1, $2, $3 }'
|
|
> md0 vnode 128M
|
|
|
|
$ diskinfo -v /dev/md0 | expand
|
|
> /dev/md0
|
|
> 512 # sectorsize
|
|
> 134217728 # mediasize in bytes (128M)
|
|
> 262144 # mediasize in sectors
|
|
> 0 # stripesize
|
|
> 0 # stripeoffset
|
|
>
|
|
|
|
$ mdconfig -du 0
|
|
|
|
# Size for vnodes - larger than the actual file.
|
|
|
|
$ mdconfig -a -t vnode -f xxx -s 128g
|
|
> md0
|
|
|
|
$ mdconfig -lv | awk '{ print $1, $2, $3 }'
|
|
> md0 vnode 128G
|
|
|
|
$ diskinfo -v /dev/md0 | expand
|
|
> /dev/md0
|
|
> 512 # sectorsize
|
|
> 137438953472 # mediasize in bytes (128G)
|
|
> 268435456 # mediasize in sectors
|
|
> 0 # stripesize
|
|
> 0 # stripeoffset
|
|
>
|
|
|
|
$ mdconfig -du 0
|
|
|
|
# Sector size for vnodes.
|
|
|
|
$ mdconfig -a -t vnode -f xxx -S 2048
|
|
> md0
|
|
|
|
$ mdconfig -lv | awk '{ print $1, $2, $3 }'
|
|
> md0 vnode 1024M
|
|
|
|
$ diskinfo -v /dev/md0 | expand
|
|
> /dev/md0
|
|
> 2048 # sectorsize
|
|
> 1073741824 # mediasize in bytes (1.0G)
|
|
> 524288 # mediasize in sectors
|
|
> 0 # stripesize
|
|
> 0 # stripeoffset
|
|
>
|
|
|
|
$ mdconfig -du 0
|
|
|
|
# Malloc type.
|
|
|
|
$ mdconfig -a -t malloc -s 1g
|
|
> md0
|
|
|
|
$ mdconfig -lv | awk '{ print $1, $2, $3 }'
|
|
> md0 malloc 1024M
|
|
|
|
$ diskinfo -v /dev/md0 | expand
|
|
> /dev/md0
|
|
> 512 # sectorsize
|
|
> 1073741824 # mediasize in bytes (1.0G)
|
|
> 2097152 # mediasize in sectors
|
|
> 0 # stripesize
|
|
> 0 # stripeoffset
|
|
>
|
|
|
|
$ mdconfig -du 0
|
|
|
|
# Swap type.
|
|
|
|
$ mdconfig -a -t swap -s 1g
|
|
> md0
|
|
|
|
$ mdconfig -lv | awk '{ print $1, $2, $3 }'
|
|
> md0 swap 1024M
|
|
|
|
$ diskinfo -v /dev/md0 | expand
|
|
> /dev/md0
|
|
> 512 # sectorsize
|
|
> 1073741824 # mediasize in bytes (1.0G)
|
|
> 2097152 # mediasize in sectors
|
|
> 0 # stripesize
|
|
> 0 # stripeoffset
|
|
>
|
|
|
|
$ mdconfig -du 0
|
|
|
|
# Attaching with a specific unit number.
|
|
|
|
$ mdconfig -as 1g -u 42
|
|
|
|
$ mdconfig -lv | awk '{ print $1, $2, $3 }'
|
|
> md42 swap 1024M
|
|
|
|
$ diskinfo -v /dev/md42 | expand
|
|
> /dev/md42
|
|
> 512 # sectorsize
|
|
> 1073741824 # mediasize in bytes (1.0G)
|
|
> 2097152 # mediasize in sectors
|
|
> 0 # stripesize
|
|
> 0 # stripeoffset
|
|
>
|
|
|
|
$ mdconfig -du 42
|
|
|
|
# Querying.
|
|
|
|
$ mdconfig -as 1g
|
|
> md0
|
|
$ mdconfig -as 2g -u 42
|
|
|
|
$ mdconfig -lv | awk '{ print $1, $2, $3 }'
|
|
> md0 swap 1024M
|
|
> md42 swap 2048M
|
|
|
|
$ mdconfig -lvu 0 | awk '{ print $1, $2, $3 }'
|
|
> md0 swap 1024M
|
|
|
|
$ mdconfig -lvu 42 | awk '{ print $1, $2, $3 }'
|
|
> md42 swap 2048M
|
|
|
|
$ mdconfig -lvu 24 | awk '{ print $1, $2, $3 }'
|
|
|
|
$ mdconfig -du 42
|
|
$ mdconfig -du 0
|
|
|
|
$ rm xxx
|