5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
33 . $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib
37 # 'zpool create -f <pool> <vspec> ...' can successfully create a
38 # new pool in some cases.
41 # 1. Prepare the scenarios for '-f' option
42 # 2. Use -f to override the devices to create new pools
43 # 3. Verify the pool created successfully
46 verify_runnable "global"
50 for pool in $TESTPOOL $TESTPOOL1; do
51 poolexists $pool && destroy_pool $pool
63 log_assert "'zpool create -f <pool> <vspec> ...' can successfully create" \
64 "a new pool in some cases."
66 create_pool $TESTPOOL $DISK0
67 log_must eval "new_fs ${DEV_RDSKDIR}/${DISK1} >/dev/null 2>&1"
68 typeset disk1=$(create_blockfile $FILESIZE)
69 typeset disk2=$(create_blockfile $FILESIZE1)
72 log_must zpool export $TESTPOOL
73 log_note "'zpool create' without '-f' will fail " \
74 "while device belongs to an exported pool."
75 log_mustnot zpool create $TESTPOOL1 $DISK0
76 create_pool $TESTPOOL1 $DISK0
77 log_must poolexists $TESTPOOL1
79 log_must destroy_pool $TESTPOOL1
81 log_note "'zpool create' without '-f' will fail " \
82 "while device is in use by a ufs filesystem."
84 # fs must be mounted for create to fail on FreeBSD
85 log_must mkdir -p $TESTDIR
86 log_must mount ${DEV_DSKDIR}/${DISK1} $TESTDIR
88 log_mustnot zpool create $TESTPOOL $DISK1
90 # fs must not be mounted to create pool even with -f
91 log_must umount -f $TESTDIR
92 log_must rm -rf $TESTDIR
94 create_pool $TESTPOOL $DISK1
95 log_must poolexists $TESTPOOL
97 log_must destroy_pool $TESTPOOL
99 log_note "'zpool create' mirror without '-f' will fail " \
100 "while devices have different size."
101 log_mustnot zpool create $TESTPOOL mirror $disk1 $disk2
102 create_pool $TESTPOOL mirror $disk1 $disk2
103 log_must poolexists $TESTPOOL
105 log_must destroy_pool $TESTPOOL
107 if ! is_freebsd; then
108 log_note "'zpool create' mirror without '-f' will fail " \
109 "while devices are of different types."
110 log_mustnot zpool create $TESTPOOL mirror $disk1 $DISK0
111 create_pool $TESTPOOL mirror $disk1 $DISK0
112 log_must poolexists $TESTPOOL
114 log_must destroy_pool $TESTPOOL
117 log_note "'zpool create' without '-f' will fail " \
118 "while a device is part of a potentially active pool."
119 create_pool $TESTPOOL mirror $DISK0 $DISK1
120 log_must zpool offline $TESTPOOL $DISK0
121 log_must zpool export $TESTPOOL
122 log_mustnot zpool create $TESTPOOL1 $DISK0
123 create_pool $TESTPOOL1 $DISK0
124 log_must poolexists $TESTPOOL1
126 log_must destroy_pool $TESTPOOL1
128 log_pass "'zpool create -f <pool> <vspec> ...' success."