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 $TESTPOOL2 $TESTPOOL3 $TESTPOOL4 \
56 clean_blockfile "$TESTDIR0 $TESTDIR1"
58 for file in $FILEDISK0 $FILEDISK1 $FILEDISK2
60 if [[ -e $TEST_BASE_DIR/$file ]]; then
61 rm -f $TEST_BASE_DIR/$file
65 partition_disk $SIZE $disk 6
70 log_assert "'zpool create -f <pool> <vspec> ...' can successfully create" \
71 "a new pool in some cases."
73 if [[ -n $DISK ]]; then
78 create_pool "$TESTPOOL" "${disk}${SLICE_PREFIX}${SLICE0}"
79 log_must echo "y" | newfs \
80 ${DEV_RDSKDIR}/${disk}${SLICE_PREFIX}${SLICE1} >/dev/null 2>&1
81 create_blockfile $FILESIZE $TESTDIR0/$FILEDISK0 ${disk}${SLICE_PREFIX}${SLICE4}
82 create_blockfile $FILESIZE1 $TESTDIR1/$FILEDISK1 ${disk}${SLICE_PREFIX}${SLICE5}
83 log_must truncate -s $SIZE $TEST_BASE_DIR/$FILEDISK0
84 log_must truncate -s $SIZE $TEST_BASE_DIR/$FILEDISK1
85 log_must truncate -s $SIZE $TEST_BASE_DIR/$FILEDISK2
88 log_must zpool export $TESTPOOL
89 log_note "'zpool create' without '-f' will fail " \
90 "while device is belong to an exported pool."
91 log_mustnot zpool create "$TESTPOOL1" "${disk}${SLICE_PREFIX}${SLICE0}"
92 create_pool "$TESTPOOL1" "${disk}${SLICE_PREFIX}${SLICE0}"
93 log_must poolexists $TESTPOOL1
95 log_note "'zpool create' without '-f' will fail " \
96 "while device is using by an ufs filesystem."
97 log_mustnot zpool create "$TESTPOOL2" "${disk}${SLICE_PREFIX}${SLICE1}"
98 create_pool "$TESTPOOL2" "${disk}${SLICE_PREFIX}${SLICE1}"
99 log_must poolexists $TESTPOOL2
101 log_note "'zpool create' mirror without '-f' will fail " \
102 "while devices have different size."
103 log_mustnot zpool create "$TESTPOOL3" "mirror" $TESTDIR0/$FILEDISK0 \
105 create_pool "$TESTPOOL3" "mirror" $TESTDIR0/$FILEDISK0 $TESTDIR1/$FILEDISK1
106 log_must poolexists $TESTPOOL3
108 log_note "'zpool create' mirror without '-f' will fail " \
109 "while devices are of different types."
110 log_mustnot zpool create "$TESTPOOL4" "mirror" $TEST_BASE_DIR/$FILEDISK0 \
111 ${disk}${SLICE_PREFIX}${SLICE3}
112 create_pool "$TESTPOOL4" "mirror" \
113 $TEST_BASE_DIR/$FILEDISK0 ${disk}${SLICE_PREFIX}${SLICE3}
114 log_must poolexists $TESTPOOL4
116 log_note "'zpool create' without '-f' will fail " \
117 "while device is part of potentially active pool."
118 create_pool "$TESTPOOL5" "mirror" $TEST_BASE_DIR/$FILEDISK1 \
119 $TEST_BASE_DIR/$FILEDISK2
120 log_must zpool offline $TESTPOOL5 $TEST_BASE_DIR/$FILEDISK2
121 log_must zpool export $TESTPOOL5
122 log_mustnot zpool create "$TESTPOOL6" $TEST_BASE_DIR/$FILEDISK2
123 create_pool $TESTPOOL6 $TEST_BASE_DIR/$FILEDISK2
124 log_must poolexists $TESTPOOL6
126 log_pass "'zpool create -f <pool> <vspec> ...' success."