Friday, June 5, 2015

How to Import and Export ZFS Pool aka ZPOOL

There are multiple way to import and export ZPOOL. These are the useful commands for all the Solaris administrator who is supporting ZFS environment.

Here I showed multiply way to import and export ZPOOL's with many scenario and example.

Please refer this link for basic pool creation - Create POOLS

To list available pools which can be import:
TID{root}# zpool import
  pool: test2
    id: 14839829789894250168
 state: ONLINE
action: The pool can be imported using its name or numeric identifier.
config:

        test2       ONLINE
          c1t4d0    ONLINE
          c1t3d0    ONLINE

  pool: zonepool
    id: 9851977220631207786
 state: ONLINE
action: The pool can be imported using its name or numeric identifier.
config:

        zonepool    ONLINE
          c1t1d0    ONLINE
TID{root}#
To import all pools which are found in above command "zpool import" , the listed pools can be exported pools:
TID{root}# zpool list
NAME    SIZE  ALLOC   FREE    CAP  HEALTH  ALTROOT
rpool  15.9G  6.34G  9.54G    39%  ONLINE  -
TID{root}# zpool import -a
TID{root}# zpool list
NAME       SIZE  ALLOC   FREE    CAP  HEALTH  ALTROOT
rpool     15.9G  6.34G  9.54G    39%  ONLINE  -
test2     3.97G  12.5M  3.96G     0%  ONLINE  -
zonepool  15.9G  11.0G  4.85G    69%  ONLINE  -
TID{root}#
To import "DESTROYED POOL":
Those disk are not used anywhere or else the data will be lost.
TID{root}# zpool import -D
  pool: strip_pool
    id: 10696204917074183490
 state: ONLINE (DESTROYED)
action: The pool can be imported using its name or numeric identifier.
config:

        strip_pool    ONLINE
          c1t2d0      ONLINE
        spares
          c1t5d0
TID{root}# zpool import -D strip_pool
TID{root}# zpool list strip_pool
NAME        SIZE    ALLOC   FREE      CAP  HEALTH  ALTROOT
strip_pool  1.98G   112K    1.98G     0%   ONLINE  -
TID{root}# zpool status strip_pool
  pool: strip_pool
 state: ONLINE
 scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        strip_pool    ONLINE       0     0     0
            c1t2d0    ONLINE       0     0     0
        spares
            c1t5d0    AVAIL

errors: No known data errors
TID{root}#
Type-2 for import "DESTROYED POOL" using Pool ID:
TID{root}# zpool import -D
  pool: apps_pool
    id: 5646360073422230766
 state: ONLINE (DESTROYED)
action: The pool can be imported using its name or numeric identifier.
config:

        apps_pool   ONLINE
          c1t2d0    ONLINE
          c1t5d0    ONLINE

  pool: poolm
    id: 11932504340727542212
 state: FAULTED (DESTROYED)
TID{root}# zpool import -D 5646360073422230766
TID{root}# zpool list
NAME        SIZE  ALLOC   FREE    CAP  HEALTH  ALTROOT
apps_pool  3.97G    94K  3.97G     0%  ONLINE  -
rpool      15.9G  6.33G  9.54G    39%  ONLINE  -
test2      3.97G  12.4M  3.96G     0%  ONLINE  -
zonepool   15.9G  11.0G  4.85G    69%  ONLINE  -
TID{root}#
Rename ZPOOL name using import command:
TID{root}# zpool list test_pool
NAME        SIZE  ALLOC   FREE    CAP  HEALTH  ALTROOT
test_pool  3.97G   146K  3.97G     0%  ONLINE  -
TID{root}# zpool export test_pool
TID{root}# zpool import test_pool apps_pool
TID{root}# zpool list apps_pool
NAME        SIZE  ALLOC   FREE    CAP  HEALTH  ALTROOT
apps_pool  3.97G   146K  3.97G     0%  ONLINE  -
TID{root}#
To export pool:
TID{root}# zpool export apps_pool
TID{root}# zpool list apps_pool
cannot open 'apps_pool': no such pool
TID{root}#
To export pool force fully:
TID{root}# zpool export -f apps_pool
TID{root}# zpool list apps_pool
cannot open 'apps_pool': no such pool
TID{root}#

0 comments:

Post a Comment