FreeBSD/ZFS disk in pool and not in a pool at the same time

Adam KÅ‚obukowski asked:

I have following status:

$ zpool status
   pool: cs01
  state: DEGRADED
 status: One or more devices has been taken offline by the administrator.
    Sufficient replicas exist for the pool to continue functioning in a
    degraded state.
 action: Online the device using 'zpool online' or replace the device with
    'zpool replace'.

scan: none requested

    NAME                      STATE     READ WRITE CKSUM
    cs01                      DEGRADED     0     0     0
      raidz1-0                DEGRADED     0     0     0
        11994499246498421261  OFFLINE      0     0     0  was /dev/ada2
        ada3                  ONLINE       0     0     0
        ada4                  ONLINE       0     0     0
      ada2                    ONLINE       0     0     0

I want to creat new pool:

      $ sudo zpool create bk01 ada5
      invalid vdev specification
      use '-f' to override the following errors:
      /dev/ada5 is part of active pool 'cs01'


     $ sudo zpool detach cs01 ada5
     cannot detach ada5: no such device in pool
     $ sudo zpool detach cs01 ada5
     cannot detach ada5: no such device in pool

So, is ada5 in cs01 or not?
Disclaimer: ada5 was ada2 one (now missing from cs01), but it has a hw error (stopped responding), so it was removed and reformated.

I messed my cs01 pool a bit, so I want to use ada5 as temporary backup so I can recreate cs01. How can I fix this mess?

My answer:

This is what zpool labelclear is for.

The disk still has ZFS metadata on it indicating that it is part of a zpool, because you removed the disk without telling ZFS about it first.

To resolve the problem, use zpool labelclear -f <device>. This will wipe the ZFS labels from the device so that it can be used in another pool. -f is required when the device label indicates that it is still active in a zpool, as in your case.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.