3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
14 # Copyright 2016 Nexenta Systems, Inc.
15 # Copyright (c) 2019 by Lawrence Livermore National Security, LLC.
18 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_labelclear
/labelclear.cfg
21 # Check that `zpool labelclear` can clear labels on removed devices.
24 # 1. Create a pool with primary, log, spare and cache devices.
25 # 2. Remove a top-level vdev, log, spare, and cache device.
26 # 3. Run `zpool labelclear` on the removed device.
27 # 4. Verify the label has been removed.
30 verify_runnable
"global"
34 poolexists
$TESTPOOL && destroy_pool
$TESTPOOL
35 rm -f $DEVICE1 $DEVICE2 $DEVICE3 $DEVICE4 $DEVICE5
39 log_assert
"zpool labelclear works for removed devices"
41 DEVICE1
="$TEST_BASE_DIR/device-1"
42 DEVICE2
="$TEST_BASE_DIR/device-2"
43 DEVICE3
="$TEST_BASE_DIR/device-3"
44 DEVICE4
="$TEST_BASE_DIR/device-4"
45 DEVICE5
="$TEST_BASE_DIR/device-5"
47 log_must truncate
-s $
((SPA_MINDEVSIZE
* 8)) $DEVICE1
48 log_must truncate
-s $SPA_MINDEVSIZE $DEVICE2 $DEVICE3 $DEVICE4 $DEVICE5
50 log_must zpool create
-f $TESTPOOL $DEVICE1 $DEVICE2 \
51 log
$DEVICE3 cache
$DEVICE4 spare
$DEVICE5
54 # Remove each type of vdev and verify the label can be cleared.
55 for dev
in $DEVICE5 $DEVICE4 $DEVICE3 $DEVICE2; do
56 log_must zpool remove
$TESTPOOL $dev
57 log_must zpool sync
$TESTPOOL
58 log_must zpool labelclear
$dev
59 log_mustnot zdb
-lq $dev
62 log_pass
"zpool labelclear works for removed devices"