1#!/bin/ksh -p 2 3# 4# This file and its contents are supplied under the terms of the 5# Common Development and Distribution License ("CDDL"), version 1.0. 6# You may only use this file in accordance with the terms of version 7# 1.0 of the CDDL. 8# 9# A full copy of the text of the CDDL should have accompanied this 10# source. A copy of the CDDL is also available via the Internet at 11# http://www.illumos.org/license/CDDL. 12# 13 14# 15# Copyright (c) 2021 by Delphix. All rights reserved. 16# Copyright (c) 2023 by Klara, Inc. 17# 18 19. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.kshlib 20 21# 22# DESCRIPTION: 23# A pool that was cleanly exported should be importable without force even if 24# the local hostid doesn't match the on-disk hostid. 25# 26# STRATEGY: 27# 1. Set a hostid. 28# 2. Create a pool. 29# 3. Export the pool. 30# 4. Change the hostid. 31# 5. Verify that importing the pool without force succeeds. 32# 33 34verify_runnable "global" 35 36function custom_cleanup 37{ 38 rm -f $HOSTID_FILE 39 cleanup 40} 41 42log_onexit custom_cleanup 43 44# 1. Set a hostid. 45log_must zgenhostid -f $HOSTID1 46 47# 2. Create a pool. 48log_must zpool create $TESTPOOL1 $VDEV0 49 50# 3. Export the pool. 51log_must zpool export $TESTPOOL1 52 53# 4. Change the hostid. 54log_must zgenhostid -f $HOSTID2 55 56# 5. Verify that importing the pool without force succeeds. 57log_must zpool import -d $DEVICE_DIR $TESTPOOL1 58 59log_pass "zpool import can import cleanly exported pool when hostid changes." 60