59
59
static int zpool_do_add(int, char **);
60
60
static int zpool_do_remove(int, char **);
61
static int zpool_do_labelclear(int, char **);
62
63
static int zpool_do_list(int, char **);
63
64
static int zpool_do_iostat(int, char **);
150
152
{ "add", zpool_do_add, HELP_ADD },
151
153
{ "remove", zpool_do_remove, HELP_REMOVE },
155
{ "labelclear", zpool_do_labelclear, HELP_LABELCLEAR },
153
157
{ "list", zpool_do_list, HELP_LIST },
154
158
{ "iostat", zpool_do_iostat, HELP_IOSTAT },
155
159
{ "status", zpool_do_status, HELP_STATUS },
571
* zpool labelclear <vdev>
573
* Verifies that the vdev is not active and zeros out the label information
577
zpool_do_labelclear(int argc, char **argv)
580
int c, fd = -1, ret = 0;
582
boolean_t inuse = B_FALSE;
583
boolean_t force = B_FALSE;
586
while ((c = getopt(argc, argv, "f")) != -1) {
592
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
603
(void) fprintf(stderr, gettext("missing vdev device name\n"));
608
if ((fd = open(vdev, O_RDWR)) < 0) {
609
(void) fprintf(stderr, gettext("Unable to open %s\n"), vdev);
614
if (zpool_in_use(g_zfs, fd, &state, &name, &inuse) != 0) {
618
(void) fprintf(stderr,
619
gettext("Unable to determine pool state for %s\n"
620
"Use -f to force the clearing any label data\n"), vdev);
628
case POOL_STATE_ACTIVE:
629
case POOL_STATE_SPARE:
630
case POOL_STATE_L2CACHE:
631
(void) fprintf(stderr,
632
gettext("labelclear operation failed.\n"
633
"\tVdev %s is a member (%s), of pool \"%s\".\n"
634
"\tTo remove label information from this device, export or destroy\n"
635
"\tthe pool, or remove %s from the configuration of this pool\n"
636
"\tand retry the labelclear operation\n"),
637
vdev, zpool_pool_state_to_name(state), name, vdev);
641
case POOL_STATE_EXPORTED:
645
(void) fprintf(stderr,
646
gettext("labelclear operation failed.\n"
647
"\tVdev %s is a member of the exported pool \"%s\".\n"
648
"\tUse \"zpool labelclear -f %s\" to force the removal of label\n"
654
case POOL_STATE_POTENTIALLY_ACTIVE:
658
(void) fprintf(stderr,
659
gettext("labelclear operation failed.\n"
660
"\tVdev %s is a member of the pool \"%s\".\n"
661
"\tThis pool is unknown to this system, but may be active on\n"
662
"\tanother system. Use \'zpool labelclear -f %s\' to force the\n"
663
"\tremoval of label information.\n"),
668
case POOL_STATE_DESTROYED:
669
/* inuse should never be set for a destoryed pool... */
675
if (zpool_clear_label(fd) != 0) {
676
(void) fprintf(stderr,
677
gettext("Label clear failed on vdev %s\n"), vdev);
565
690
* zpool create [-fn] [-o property=value] ...
566
691
* [-O file-system-property=value] ...
567
692
* [-R root] [-m mountpoint] <pool> <dev> ...
1087
1212
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NOT_PRESENT,
1088
¬present) == 0) {
1213
¬present) == 0 ||
1214
vs->vs_state <= VDEV_STATE_CANT_OPEN) {
1090
verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0);
1091
(void) printf(" was %s", path);
1216
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0)
1217
(void) printf(" was %s", path);
1092
1218
} else if (vs->vs_aux != 0) {
1093
1219
(void) printf(" ");